Ever since the exam session started, Marcel's son keeps attending parties over and over. This time around he's facing drinks arranged on lines, each line having drinks. We know the content of the drink on position as (integer which can be negative). In one sitting, our character can choose between doing one of the actions:
- Drinks all the drinks from the first line
- Drinks all the drinks from the first column
- Drinks all the drinks from the last line
- Drinks all the drinks from the last column
Of course, in order to not face shame, he can't conduct an action which would result in him drinking less than units in one sitting. After the turn, the drinks will be eliminated from the grid and the party goes on. At any moment, our character can stop (mandatory when all drinks are gone).
Task
In the next day, Marcel found from trustworthy sources the values of , and and he's interested in finding the number of ways in which the party could have gone, modulo . Two ways are considered distinct if there is a moment at which Marcel's son chose different actions among the possible actions (the four actions resulting in him drinking, as well as stopping).
Input data
The first line will contain two numbers, and , separated by a space. lines, each of them containing integers follow. The number from line represents the value of .
Output data
The first line will contain a single number, , representing the number of ways in which the party can go, modulo .
Constraints and clarifications
Example 1
stdin
1 10
23
stdout
5
Explanation
In the first test case the party has only one round, in which the main character can choose between consuming units (possible in distinct ways) or stopping right away.
Example 2
stdin
1 23
10
stdout
1
Explanation
In the second test case the consumption of only units would be shameful, so we only have the option of stopping right away.
Example 3
stdin
2 10
23 23
23 23
stdout
53
Example 4
stdin
3 4
1 4 2
3 9 -6
7 8 5
stdout
62