Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

D. Three Sons

time limit per test

1 secondmemory limit per test

256 megabytesinput

input.txtoutput

output.txtThree sons inherited from their father a rectangular corn fiend divided into *n* × *m* squares. For each square we know how many tons of corn grows on it. The father, an old farmer did not love all three sons equally, which is why he bequeathed to divide his field into three parts containing *A*, *B* and *C* tons of corn.

The field should be divided by two parallel lines. The lines should be parallel to one side of the field and to each other. The lines should go strictly between the squares of the field. Each resulting part of the field should consist of at least one square.

Your task is to find the number of ways to divide the field as is described above, that is, to mark two lines, dividing the field in three parts so that on one of the resulting parts grew *A* tons of corn, *B* on another one and *C* on the remaining one.

Input

The first line contains space-separated integers *n* and *m* — the sizes of the original (1 ≤ *n*, *m* ≤ 50, *max*(*n*, *m*) ≥ 3). Then the field's description follows: *n* lines, each containing *m* space-separated integers *c*_{ij}, (0 ≤ *c*_{ij} ≤ 100) — the number of tons of corn each square contains. The last line contains space-separated integers *A*, *B*, *C* (0 ≤ *A*, *B*, *C* ≤ 10^{6}).

Output

Print the answer to the problem: the number of ways to divide the father's field so that one of the resulting parts contained *A* tons of corn, another one contained *B* tons, and the remaining one contained *C* tons. If no such way exists, print 0.

Examples

Input

3 3

1 1 1

1 1 1

1 1 1

3 3 3

Output

2

Input

2 5

1 1 1 1 1

2 2 2 2 2

3 6 6

Output

3

Input

3 3

1 2 3

3 1 2

2 3 1

5 6 7

Output

0

Note

The lines dividing the field can be horizontal or vertical, but they should be parallel to each other.

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/11/2017 03:11:55 (c2).

Desktop version, switch to mobile version.

User lists

Name |
---|