Given an dimensional grid with coordinates in the form
, determine the number of shortest paths from
to
, that do not pass through
blocked points.
A path consists of a series of movements where for any single movement, you must increase a single by
unit.
Input Specification
The first line will contain a single integer, ,
.
The next line will contain integers representing
,
.
The next line will contain a single integer, ,
.
The next lines will each contain a single coordinate point
,
.
The points will be unique and will not include
or
.
Output Specification
The number of ways to traverse the grid, modulo .
Sample Input
2
3 4
2
2 2
1 4
Sample Output
3
Comments