#abc271f. [abc271_f]XOR on Grid Path

[abc271_f]XOR on Grid Path

Problem Statement

There is a grid with NN rows and NN columns. We denote by (i,j)(i, j) the square at the ii-th (1leqileqN)(1 \\leq i \\leq N) row from the top and jj-th (1leqjleqN)(1 \\leq j \\leq N) column from the left.
Square (i,j)(i, j) has a non-negative integer ai,ja_{i, j} written on it.

When you are at square (i,j)(i, j), you can move to either square (i+1,j)(i+1, j) or (i,j+1)(i, j+1). Here, you are not allowed to go outside the grid.

Find the number of ways to travel from square (1,1)(1, 1) to square (N,N)(N, N) such that the exclusive logical sum of the integers written on the squares visited (including (1,1)(1, 1) and (N,N)(N, N)) is 00.

What is the exclusive logical sum? The exclusive logical sum aoplusba \\oplus b of two integers aa and bb is defined as follows.

  • The 2k2^k's place (kgeq0k \\geq 0) in the binary notation of aoplusba \\oplus b is 11 if exactly one of the 2k2^k's places in the binary notation of aa and bb is 11; otherwise, it is 00.

For example, 3oplus5=63 \\oplus 5 = 6 (In binary notation: 011oplus101=110011 \\oplus 101 = 110).
In general, the exclusive logical sum of kk integers p1,dots,pkp_1, \\dots, p_k is defined as $(\\cdots ((p_1 \\oplus p_2) \\oplus p_3) \\oplus \\cdots \\oplus p_k)$. We can prove that it is independent of the order of p1,dots,pkp_1, \\dots, p_k.

Constraints

  • 2leqNleq202 \\leq N \\leq 20
  • $0 \\leq a_{i, j} \\lt 2^{30} \\, (1 \\leq i, j \\leq N)$
  • All values in the input are integers.

Input

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

NN a1,1a_{1, 1} ldots\\ldots a1,Na_{1, N} vdots\\vdots aN,1a_{N, 1} ldots\\ldots aN,Na_{N, N}

Output

Print the answer.


Sample Input 1

3
1 5 2
7 0 5
4 2 3

Sample Output 1

2

The following two ways satisfy the condition:

  • $(1, 1) \\rightarrow (1, 2) \\rightarrow (1, 3) \\rightarrow (2, 3) \\rightarrow (3, 3)$;
  • $(1, 1) \\rightarrow (2, 1) \\rightarrow (2, 2) \\rightarrow (2, 3) \\rightarrow (3, 3)$.

Sample Input 2

2
1 2
2 1

Sample Output 2

0

Sample Input 3

10
1 0 1 0 0 1 0 0 0 1
0 0 0 1 0 1 0 1 1 0
1 0 0 0 1 0 1 0 0 0
0 1 0 0 0 1 1 0 0 1
0 0 1 1 0 1 1 0 1 0
1 0 0 0 1 0 0 1 1 0
1 1 1 0 0 0 1 1 0 0
0 1 1 0 0 1 1 0 1 0
1 0 1 1 0 0 0 0 0 0
1 0 1 1 0 0 1 1 1 0

Sample Output 3

24307