#abc265e. [abc265_e]Warp
[abc265_e]Warp
Problem Statement
Takahashi is at the origin of a two-dimensional plane.
Takahashi will repeat teleporting times. In each teleportation, he makes one of the following moves:
- Move from the current coordinates to
- Move from the current coordinates to
- Move from the current coordinates to
There are obstacles on points on the plane; he cannot teleport to these coordinates.
How many paths are there resulting from the teleportations? Find the count modulo .
Constraints
- , , and are distinct.
- are distinct.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 2
1 1 1 2 1 3
1 2
2 2
Sample Output 1
5
The following paths are possible:
Sample Input 2
10 3
-1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
-1000000000 -1000000000
1000000000 1000000000
-1000000000 1000000000
Sample Output 2
0
Sample Input 3
300 0
0 0 1 0 0 1
Sample Output 3
292172978