There is a grid with
In the grid,
Taro will start from Square
Find the number of Taro's paths from Square
Constraints
- All values in input are integers.
- Squares
are all distinct. - Squares
and are empty squares.
Input Specification
The first line will contain three integers,
The next
Output Specification
Print the number of Taro's paths from Square
Sample Input 1
Copy
3 4 2
2 2
1 4
Sample Output 1
Copy
3
Explanation For Sample 1
There are three paths as follows:
Sample Input 2
Copy
5 2 2
2 1
4 2
Sample Output 2
Copy
0
Explanation For Sample 2
There may be no paths.
Sample Input 3
Copy
5 5 4
3 1
3 5
1 3
5 3
Sample Output 3
Copy
24
Sample Input 4
Copy
100000 100000 1
50000 50000
Sample Output 4
Copy
123445622
Explanation For Sample 4
Be sure to print the count modulo
Comments