#ABC4074. Domino Covering XOR

Domino Covering XOR

Time Limit: 2 sec / Memory Limit: 1024 MB

Problem Statement

There is a grid with HH rows and WW columns. Let (i,j)(i,j) denote the cell at the ithi-th row from the top (1iH)(1≤i≤H) and the jthj-th column from the left (1jW)(1≤j≤W).

Cell (i,j)(1iH,1jW)(i,j) (1≤i≤H,1≤j≤W) has a non-negative integer Ai,jA_{i,j} written on it.

Let us place zero or more dominoes on the grid. AA domino covers two adjacent cells, namely one of the following pairs:

1、cells (i,j)(i,j) and (i,j+1)(i,j+1) for 1iH,1j<W1≤i≤H,1≤j<W;

2、cells (i,j)(i,j) and (i+1,j)(i+1,j) for 1i<H,1jW1≤i<H,1≤j≤W.

No cell may be covered by more than one domino.

For a placement of dominoes, define its score as the bitwise XORXOR of all integers written in cells not covered by any domino.

Find the maximum possible score.

What is bitwise XORXOR?

For non-negative integers AA and BB, their bitwise XORABXOR A⊕B is defined as follows:

In binary, the 2k2_k bit (k0)(k≥0) of ABA⊕B is 11 if exactly one of AA and BB has 11 in that bit, and 00 otherwise. For example, 35=63⊕5=6 (in binary, 011101=110011⊕101=110). For kk non-negative integers p1,p2,p3,,pkp_1 ,p_2 ,p_3 ,…,p_k , their bitwise XORXOR is (((p1p2)p3)...pk)(…((p_1⊕p_2 )⊕p_3)⊕...⊕p_k ), which can be proved to be independent of the order of the operands.

Constraints

1H1≤H

1W1≤W

HW20HW≤20

0Ai,j<260(1iH,1jW)0≤A_{i,j} <2^{60} (1≤i≤H, 1≤j≤W)

All input values are integers.

Input

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

HWH W

A1,1A1,2A1,WA_{1,1}A_{1,2}… A_{1,W}

A2,1A2,2A2,WA_{2,1}A_{2,2}… A_{2,W}

AH,1AH,2AH,WA_{H,1}A_{H,2}… A_{H,W}

Output

Output the answer.

Sample Input 1

3 4
1 2 3 8
4 0 7 10
5 2 4 2

Sample Output 1

15

The grid is as follows:

For example, the placement below yields a score of 15.

No placement achieves a score of 16 or higher, so output 15.

Sample Input 2

1 11
1 2 4 8 16 32 64 128 256 512 1024

Sample Output 2

2047

You may also choose to place no dominoes.

Sample Input 3

4 5
74832 16944 58683 32965 97236
52995 43262 51959 40883 58715
13846 24919 65627 11492 63264
29966 98452 75577 40415 77202

Sample Output 3

131067