Three 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.
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*<sub class="lower-index">*ij*</sub>, (0 ≤ *c*<sub class="lower-index">*ij*</sub> ≤ 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<sup class="upper-index">6</sup>).
3 3
1 1 1
1 1 1
1 1 1
3 3 3
2
2 5
1 1 1 1 1
2 2 2 2 2
3 6 6
3
3 3
1 2 3
3 1 2
2 3 1
5 6 7
0
3 3
0 0 0
0 0 1
1 1 0
2 1 0
1
3 3
0 0 0
0 1 0
0 0 0
1 0 0
2
3 2
0 0
0 2
0 0
2 0 0
1
3 2
0 1
2 1
0 1
3 1 1
1
5 10
0 1 4 4 4 1 4 0 0 4
1 1 2 0 4 4 2 2 0 3
3 2 4 0 3 0 1 3 1 0
4 1 2 3 0 2 0 2 0 1
4 4 4 0 2 4 3 1 3 2
10 78 12
2
5 10
0 0 0 0 0 0 0 0 0 0
0 2 0 1 0 5 0 3 0 4
0 0 0 0 0 0 0 0 0 0
0 2 0 4 0 3 0 3 0 2
0 0 0 0 0 0 0 0 0 0
0 15 14
5
10 10
2 0 1 5 5 0 4 1 2 0
3 5 2 5 4 0 2 3 4 0
4 0 3 0 5 1 2 3 4 4
1 3 2 0 5 2 4 3 5 0
5 0 1 5 1 4 4 2 1 2
3 2 0 4 0 0 0 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0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
5 20 10
24
10 15
2 91 9 36 34 23 88 86 19 91 29 41 39 47 9
66 63 69 60 73 19 93 78 15 38 70 39 36 4 49
93 4 25 32 31 49 33 76 22 83 60 49 47 27 20
34 9 29 85 84 59 8 87 92 5 44 4 60 63 74
92 50 27 78 62 88 2 50 95 29 37 3 42 72 80
41 72 35 1 35 85 42 64 41 79 58 2 41 4 11
2 3 19 77 97 52 74 37 16 58 57 44 14 94 41
5 47 75 72 49 52 41 48 59 56 38 54 81 9 50
54 6 46 52 39 79 30 52 79 68 76 40 44 38 68
7 12 11 87 78 23 47 14 27 83 83 14 84 54 69
289 5446 1371
0
30 2
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0 0
406
30 2
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
0 0
0 1
12 2 1
24
30 2
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
34 34
1836 68 136
6
40 4
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
0 0 0 0
0 1 0 1
34 4 2
24
40 4
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0
744
n,m = map(int,input().split())
A = [[int(x) for x in input().split()] for _ in range(n)]
a,b,c = map(int,input().split())

combs = {(a,b,c),
         (a,c,b),
         (b,a,c),
         (c,a,b),
         (c,b,a),
         (b,c,a)}

if sum(sum(x) for x in A) != a+b+c:
    print(0)
else:
    res = 0

    X = [0]
    for i in range(n):
        X.append(X[-1] + sum(A[i][j] for j in range(m)))
    Y = [0]
    for i in reversed(range(n)):
        Y.append(Y[-1] + sum(A[i][j] for j in range(m)))
    for x,y,z in combs:
        if x in X and y in Y:
            res += 1

    X = [0]
    for j in range(n):
        X.append(X[-1] + sum(A[i][j] for i in range(n)))
    Y = [0]
    for j in reversed(range(n)):
        Y.append(Y[-1] + sum(A[i][j] for i in range(n)))
    for x,y,z in combs:
        if x in X and y in Y:
            res += 1
    print(res)

