#SL2310A. Almost Acyclic

Almost Acyclic

Almost Acyclic

We call a connected undirected graph almost-acyclic, if the graph has no cycles, or all the simple cycles in it share at least one common point.

You are given a complete undirected graph G=(V,E)G=(V,E) with nn vertices. Each edge (i,j)(i,j) has a weight wi,jw_{i,j}. Calculate (f(G)f(G) is 11 if GG is almost-acyclic, or 00 otherwise):

$$\sum_{E'\subseteq E,\: G'=(V,E')} f(G') \prod_{(i,j) \in E'} w_{i,j} \bmod 10^9+7 $$

Input

The first line contains a single integer T(1T16)T \: (1\leq T \leq 16), denoting the number of test cases.

For each test case, the first line contains an integer n(1n16)n \: (1\leq n \leq 16).

The next nn lines each contains nn integers. The jj-th number in the ii-th line denotes wi,j(0wi,j<109+7)w_{i,j} \: (0 \leq w_{i,j} < 10^9+7) .

It is guaranteed that wi,j=wj,iw_{i,j} \: = w_{j,i}, wi,i=0w_{i,i} = 0.

It is guaranteed that for each 1i161 \leq i \leq 16, there is at most one test case satisfying n=in = i.

Output

For each test case, output one line with an integer denoting the answer.

Example

2
3
0 1 2
1 0 1
2 1 0
5
0 1 0 1 1
1 0 1 1 1
0 1 0 1 0
1 1 1 0 1
1 1 0 1 0
7
120