Limitless Matrix
题号:NC15340
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

Today, Mr.Frog gets two integers N and K, he wants to construct a matrix M that satisfies the following conditions:
1. Matrix M consists of N rows and N columns. The element at ith row and jth column in the matrix M is Mi,j.

2. The product of arbitrary rows in matrix M is K.
3. The product of arbitrary columns in matrix M is K.
4. The product of the main diagonal line is K.
5. The product of the sub diagonal line is K.
6. Arbitrary element in the matrix M is an integer.
7. For arbitrary i ∈ [1,n], j ∈ [1,n] should be satisfied |Mi,j| < |K|.

For example, when N = 5, the matrix M consists of 5 rows and 5 columns.

The ith row consists of Mi,1, Mi,2, Mi,3, Mi,4 and Mi,5.
The jth column consists of M1,j, M2,j, M3,j, M4,j and M5,j.

The main diagonal line consists of M1,1, M2,2, M3,3, M4,4 and M5,5
The sub diagonal line consists of M1,5, M2,4, M3,3, M4,2 and M5,1.

However, Mr.Frog will go to Hong Kong today. He asks you for help.

输入描述:

The first line contains an integer T, where T is the number of test cases. T test cases follow. 
For each test case, the only line contains two integers N and K.

• 1 ≤ T ≤ 10.
• 1 ≤ N ≤ 103.
• −109 ≤ K ≤ 109.

输出描述:

For each test case, output one line containing “Case #x:”, where x is the test case number (starting from
1). If there is no solution, print “IMPOSSIBLE” in the next line; otherwise, print N lines with N integers.
If there are many multiple optimal answers, output any one of them.
示例1

输入

复制
2
5 -7
3 373248

输出

复制
Case #1:
IMPOSSIBLE
Case #2:
36 108 96
192 72 27
54 48 144