Skip to content

Kevin's Home

ZOJ month contest D.Determinant and Matrix

数论1 min read


Time Limit: 2 Seconds      Memory Limit: 65536 KB

Description

Recently, LBH is learning the curse linear algebra. Thus he is very interested in matrix and determinant now. In order to practice his ability of solving the problem of linear algebra, he just invent some problems by himself. Once the problems was create, he would solve it immediately. However, he meet a problem that was so hard that he couldn't work out even though racked his brains. The problem was described as follow:

To a integer martix Mnn(aij), we define two function add(Mnn(aij))=Mnn(aij + 1) and sub(Mnn(aij))=Mnn(aij - 1) which were exactly like this:

![DeterminantAndMatrixFig1](http://acm.zju.edu.cn/onlinejudge/showImage.do?name=DeterminantAndMatrixFig1.png)
![DeterminantAndMatrixFig2](http://acm.zju.edu.cn/onlinejudge/showImage.do?name=DeterminantAndMatrixFig2.png)

According to the martix Mnn(aij), we can permutate it and get a full permutation set Perm(Mnn(aij)) = {Mnn(aIiJj)| I and J is a permutation of 1..n }, (Perm(M) is a set, each matrix in Perm(M) is unique). For example:

![DeterminantAndMatrixFig3](http://acm.zju.edu.cn/onlinejudge/showImage.do?name=DeterminantAndMatrixFig3.png)

The problem is to get the result of a fomula about an integer matrix Mnn:

![DeterminantAndMatrixFig4](http://acm.zju.edu.cn/onlinejudge/showImage.do?name=DeterminantAndMatrixFig4.png)
in which the det(M) meaned to cacluate the determinant of M.

Input

There are several test cases.

The first line contains an integer T(T ≤ 100) . Then T test cases follow.

In each test case, the first line contains one integer n(0< n≤ 10). The number means the giving matrix's size is n×n

Then there are n lines followed, each line contains n integers aij(-10≤ aij≤ 10), in the position row i, colum j, it represents the number aij.

Output

For each test case, since the result may be very large, output one line with the result modulo 230.

Sample Input

Sample Output

Author: **LIN, Binghui**Source: **ZOJ Monthly, August 2014**

这道题全场现场只A了一个人。今天我们比赛的时候我A了,挺爽的。