AT_abc407_d [ABC407D] Domino Covering XOR

Description

There is a grid with $ H $ rows and $ W $ columns. Let $ (i,j) $ denote the cell at the $ i $ -th row from the top $ (1\leq i\leq H) $ and the $ j $ -th column from the left $ (1\leq j\leq W) $ . Cell $ (i,j)\ (1\leq i\leq H,1\leq j\leq W) $ has a non-negative integer $ A_{i,j} $ written on it. Let us place zero or more dominoes on the grid. A domino covers two adjacent cells, namely one of the following pairs: - cells $ (i,j) $ and $ (i,j+1) $ for $ 1\leq i\leq H,1\leq j\lt W $ ; - cells $ (i,j) $ and $ (i+1,j) $ for $ 1\leq i\lt H,1\leq j\leq W $ . No cell may be covered by more than one domino. For a placement of dominoes, define its **score** as the bitwise XOR of all integers written in cells **not** covered by any domino. Find the maximum possible score. What is bitwise XOR? For non-negative integers $ A $ and $ B $ , their bitwise XOR $ A \oplus B $ is defined as follows: - In binary, the $ 2^k $ bit ( $ k \ge 0 $ ) of $ A \oplus B $ is $ 1 $ if exactly one of $ A $ and $ B $ has $ 1 $ in that bit, and $ 0 $ otherwise. For example, $ 3 \oplus 5 = 6 $ (in binary, $ 011 \oplus 101 = 110 $ ). For $ k $ non-negative integers $ p_1, p_2, p_3, \dots, p_k $ , their bitwise XOR is $ (\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k) $ , which can be proved to be independent of the order of the operands.

Input Format

The input is given from Standard Input in the following format: > $ H $ $ W $ $ A _ {1,1} $ $ A _ {1,2} $ $ \ldots $ $ A _ {1,W} $ $ A _ {2,1} $ $ A _ {2,2} $ $ \ldots $ $ A _ {2,W} $ $ \vdots $ $ A _ {H,1} $ $ A _ {H,2} $ $ \ldots $ $ A _ {H,W} $

Output Format

Output the answer.

Explanation/Hint

### Sample Explanation 1 The grid is as follows: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/AT_abc407_d/f6907d24f41d5d47d19def623f2a90490a2103ed071270c07646c263b0d04ea4.png) For example, the placement below yields a score of $ 15 $ . ![](https://cdn.luogu.com.cn/upload/vjudge_pic/AT_abc407_d/c0d99db9dcfc6de65f7d4322f3385819b0a890debe525f2e34078d38752fb071.png) No placement achieves a score of $ 16 $ or higher, so output `15`. ### Sample Explanation 2 You may also choose to place no dominoes. ### Constraints - $ 1 \le H $ - $ 1 \le W $ - $ HW \le 20 $ - $ 0 \le A_{i,j} < 2^{60} $ ( $ 1 \le i \le H,\ 1 \le j \le W $ ) - All input values are integers.