EzParallelogram

Time limit: 4s Memory limit: 1024MB Input: Output:

After a long search, Gaudeamus the Miner has discovered a rectangular vein of bitrock ore.

The vein can be represented as an n×mn \times m matrix aa, where ai,ja_{i,j} denotes the amount of bitrock ore in that particular region of the vein. However, the Parallelogram Mining Company decided that Gaudeamus must avoid mining in some regions (due to safety concerns). For those regions, ai,j=1a_{i,j}=-1.

Additionally, Gaudeamus is equipped with a single Parallelogram Mining Explosive that can automatically extract the ore from a parallelogram-shaped subregion of his choice that does not contain any regions that are unsafe to mine in:

The profit obtained from an explosion is equal to the bitwise XOR of the amounts of ore from each of the regions affected by the explosion.

Task

Find the maximum profit that Gaudeamus the Miner can obtain.

Input data

The first line of input contains two integers nn and mm — the height and width of the vein, respectively.

Each of the next nn lines (1in1 \le i \le n) of input contain mm integers ai,1,ai,2,,ai,ma_{i,1},a_{i,2},\ldots,a_{i,m} — the amount of ore in each region.

Output data

Print one integer, the maximum profit that Gaudeamus the Miner can obtain.

Constraints and clarifications

  • 2n102 \le n \le 10
  • 2m21052 \le m \le 2 \cdot 10^5
  • 4nm41054 \le n\cdot m \le 4 \cdot 10^5
  • 1ai,j<260-1 \le a_{i,j} \lt 2^{60}
  • There exists at least one cell that Gaudeamus can mine in.

Example 1

stdin

3 4
-1 -1 1 2
-1 4 8 -1
16 32 -1 -1

stdout

63

Explanation

The answers for the examples are the first 4 valid parallelograms depicted in the statement.

The profit obtained by Gaudeamus is equal to 12481632=631 \oplus 2 \oplus 4 \oplus 8 \oplus 16 \oplus 32 = 63, where \oplus denotes the bitwise XOR operation.

Example 2

stdin

5 5
0 10 3 2 11
7 6 1 3 8
-1 9 -1 8 0
0 0 3 0 -1
0 -1 4 -1 11

stdout

14

Explanation

The profit obtained by Gaudeamus is equal to 3211613=143 \oplus 2 \oplus 11 \oplus 6 \oplus 1 \oplus 3 = 14.

Example 3

stdin

3 4
6 -1 9 -1
7 -1 3 11
4 4 7 6

stdout

12

Explanation

The profit obtained by Gaudeamus is equal to 117=1211 \oplus 7 = 12.

Example 4

stdin

2 2
576460752303423488 576460752303423489
576460752303423489 864691128455135232

stdout

864691128455135232

Explanation

The profit obtained by Gaudeamus is simply equal to 864691128455135232864691128455135232, as that is the only cell affected by the explosion.

Log in or sign up to be able to send submissions!