Koşar Farm

View as PDF

Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Problem types

Your local farmer friend Koşar and his son Koşaroğlu are growing floppy disks on their \(\mathbf{N} \times \mathbf{M}\) rectangle-shaped land. They want your help to meet CCLUB's floppy disk order in time. However, they can only sow a rectangular area of \(\mathbf{X} \times \mathbf{Y}\) inside the land they own since they have a limited amount of floppy disk seeds.

In the farm of the Koşar family, each of the land pieces has a fertility value \(\mathbf{V_{ij}}\). To find the fertility value of an area you need to apply exclusive or operation to the fertility values inside the area.

For example, if the area is between coordinates (1, 1) and (2, 2), the fertility value of this area is calculated as follows:

\( \mathbf{V_{11}} \oplus \mathbf{V_{12}} \oplus \mathbf{V_{21}} \oplus \mathbf{V_{22}} \)

Can you help Koşar and Koşaroğlu to find the maximum fertility value of the area they can sow?

Input

In the first line of each test case, integers \(\mathbf{N}\), \(\mathbf{M}\), \(\mathbf{X}\) and \(\mathbf{Y}\) (that are the length and the width of the farm, and the length and the width of the area that would be selected to sow, respectively) are given.

In the following \(\mathbf{N} \times \mathbf{M}\) grid, the farm is given. Each value \(\mathbf{V_{ij}}\) in this grid has the fertility value of the corresponding coordinate.

  • \(1 \leq \mathbf{X} \leq \mathbf{N} \leq 10^5\)
  • \(1 \leq \mathbf{Y} \leq \mathbf{M} \leq 10^5\)
  • \(1 \leq \mathbf{V_{ij}} \leq 10^5\)

Output

Only print the fertility of the \(\mathbf{X} \times \mathbf{Y}\) area.

Examples

Input 1:

3 3 2 2
9 5 3
4 10 5
3 5 7

Output 1:

13

Input 2:

4 5 3 2
1 9 2 8 7
9 4 6 9 7
8 2 8 6 2
7 3 2 2 8

Output 2:

15

Explanation

Input 1

The area between coordinates (1, 1) and (2, 2) has a fertility value of 2.

\( 9 \oplus 5 \oplus 4 \oplus 10 = 2 \)

The area between coordinates (1, 2) and (2, 3) has a fertility value of 9.

\( 5 \oplus 3 \oplus 10 \oplus 5 = 9 \)

The area between coordinates (2, 1) and (3, 2) has a fertility value of 8.

\( 4 \oplus 10 \oplus 3 \oplus 5 = 8 \)

The area between coordinates (2, 2) and (3, 3) has a fertility value of 13.

\( 10 \oplus 5 \oplus 5 \oplus 7 = 13 \)

So the maximum fertility value is 13 with the area between coordinates (2, 2) and (3, 3).

Input 2

The maximum fertility value is 15 with the area between coordinates (1, 1) and (3, 2).