atcoder#CF16EXHIBITIONFINALH. AB=C Problem

AB=C Problem

Score : 15001500 points

Problem Statement

Snuke received two matrices AA and BB as birthday presents. Each of the matrices is an NN by NN matrix that consists of only 00 and 11.

Then he computed the product of the two matrices, C=ABC = AB. Since he performed all computations in modulo two, CC was also an NN by NN matrix that consists of only 00 and 11. For each 1i,jN1 \leq i, j \leq N, you are given ci,jc_{i, j}, the (i,j)(i, j)-element of the matrix CC.

However, Snuke accidentally ate the two matrices AA and BB, and now he only knows CC. Compute the number of possible (ordered) pairs of the two matrices AA and BB, modulo 109+710^9+7.

Constraints

  • 1N3001 \leq N \leq 300
  • ci,jc_{i, j} is either 00 or 11.

Input

The input is given from Standard Input in the following format:

NN

c1,1c_{1, 1} ...... c1,Nc_{1, N}

:

cN,1c_{N, 1} ...... cN,Nc_{N, N}

Output

Print the number of possible (ordered) pairs of two matrices AA and BB (modulo 109+710^9+7).

2
0 1
1 0
6
10
1 0 0 1 1 1 0 0 1 0
0 0 0 1 1 0 0 0 1 0
0 0 1 1 1 1 1 1 1 1
0 1 0 1 0 0 0 1 1 0
0 0 1 0 1 1 1 1 1 1
1 0 0 0 0 1 0 0 0 0
1 1 1 0 1 0 0 0 0 1
0 0 0 1 0 0 1 0 1 0
0 0 0 1 1 1 0 0 0 0
1 0 1 0 0 1 1 1 1 1
741992411