Bounding Box
题号:NC213129
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Bobo has a matrix of size filled with integers. It is guaranteed that all cells which contain the same value are 4-side connected.

Let's define a *bounding box* B_x of a connected component with value x as minimum-area rectangle (with sides parallel to the matrix sides) that covers all cells of the component.

For each bounding box B_x, Bobo would like to find the value of



where A is the set of all integers in the matrix and

输入描述:

The input consists of several test cases terminated by end-of-file. For each test case:

The first line contains two integers n and m -- the size of the matrix.

The second line contains integers , , , , where is the value in the i-th row and the j-th column.

*
*
* It is guaranteed that all cells which contain the same value are 4-side connected.
* It is guaranteed that the sum of in all test cases does not exceed .

输出描述:

For each test case, output an integer denoting the value of , where  denotes the exclusive-or (XOR) operator.
示例1

输入

复制
4 2
4 8 4 4 4 2 2 2
2 7
12 12 12 13 8 9 14 12 12 7 4 10 11 5
3 5
13 13 3 3 14 2 2 1 1 11 2 2 1 5 7

输出

复制
20
93
56