Skip to content## ZOJ month contest D.Determinant and Matrix

Time Limit: 2 Seconds Memory Limit: 65536 KB

## Description

## Input

## Output

## Sample Input

#### Sample Output

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

— 数论 — 1 min read

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 M_{nn}(a_{ij}), we define two function add(M_{nn}(a_{ij}))=M_{nn}(a_{ij} + 1) and sub(M_{nn}(a_{ij}))=M_{nn}(a_{ij} - 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 M_{nn}(a_{ij}), we can permutate it and get a full permutation set Perm(M_{nn}(a_{ij})) = {M_{nn}(a_{IiJj})| 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 M_{nn}:

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

in which the det(M) meaned to cacluate the determinant of M.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 `a _{ij}`(-10≤

For each test case, since the result may be very large, output one line with the result modulo 2^{30}.

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