In an alternate universe, the game of Chess is played on an by board (with cell being on the bottom left and cell on the top right). Pawns in this game can only move forward diagonally. That is, a pawn at cell may only move to cells so long as the cell is inside the board.
There is a pawn at cell . For different cells determine the number of ways the pawn can reach that cell with a non-negative number of legal moves. Because this number may be large, output the answer modulo .
Constraints
Input Specification
The first line of input will contain integers , , , , and .
The next lines will contain space-separated integers for that query.
Output Specification
For each of the queries output the number of ways the pawn can reach the cell with a non-negative number of legal moves modulo , on a new line.
Sample Input
3 4 2 2 3
2 4
2 3
1 1
Sample Output
2
0
0
Explanation
.1.
.2.
.P.
3..
The pawn is at P
in the diagram above. The first query is at cell , 1
in the diagram. There are two possible ways to get there. The first is going to cell then to . The second is going to cell then to .
For the second query, there are no ways to reach the cell. This is also the case for the third query as a pawn may not move backwards.
Comments