OpenJudge

C19J:Matrix of Determinants

总时间限制:
2000ms
内存限制:
65536kB
描述

We've known quite a lot about the determinant of an matrix from linear algebra course and we now take a review


in which is the set of permutations of , and

Now given an matrix , define as the remaining submatrix after deleting the row and the line of . For example, assume , then , , .

Your task is to compute the determinant of for any modulo .

输入

The first line contains an integer , indicating the number of matrices.

Then matrices follow. For each matrix , the first line contains an integer indicating the size of .

The following lines give the matrix. The line contains non-negative integers less than separated by a space, describing the row of the matrix.

The input guarantees that and , and the number of matrices with is no more than 3.

输出

For each input matrix, output an matrix , in which modulo . Output an extra empty line at the end of each output matrix.

样例输入
3
2
4 6
2 3
3
1 0 2
0 1 0
0 0 1
3
1 1 1
2 3 4
0 0 1
样例输出
3 2
6 4

1 0 0
0 1 0
998244351 0 1

3 2 0
1 1 0
1 2 1

全局题号
18834
添加于
2019-05-12
提交次数
128
尝试人数
18
通过人数
16