Dhoni has a field divided into squares of the same area. The amount of rice at each square will be given. He wants to divide his field into three parts containing , , and tons of rice. The field should be divided by two parallel lines. The lines should be parallel to one side of the field. The lines should not intersect any square. 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 into three parts so that one of the resulting parts contain tons of rice, on another one, and on the remaining one.
The first line contains space-separated integers and — the sizes of the original field . Then the field's description follows:
lines, each containing space-separated integers — the number of tons of rice each square contains.
The last line contains three space-separated integers .
Print the answer to the problem: the number of ways to divide Dhoni’s field.
Input | Output |
---|---|
3 3 0 0 0 0 0 1 1 1 0 2 1 0 | 1 |
Input | Output |
---|---|
3 3 1 2 3 3 1 2 2 3 1 5 6 7 | 0 |
Input | Output |
---|---|
2 5 1 1 1 1 1 2 2 2 2 2 3 6 6 | 3 |
Input | Output |
---|---|
3 3 1 1 1 1 1 1 1 1 1 3 3 3 | 2 |