

Time Limit: 3 sec / Memory Limit: 1024 MB
配点 : 点
問題文
次元平面の原点に高橋君がいます。
高橋君はこれから、ワープを 回繰り返します。各ワープでは、以下の つのうちいずれか つを行います。
- 現在いる座標 から に移動する
- 現在いる座標 から に移動する
- 現在いる座標 から に移動する
平面上の 箇所 には障害物があり、これらの座標に移動することはできません。
回のワープによる移動経路として考えられるものは何通りですか? で割ったあまりを求めてください。
制約
- は相異なる
- は相異なる
- 入力に含まれる値は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
出力
答えを出力せよ。
入力例 1Copy
2 2 1 1 1 2 1 3 1 2 2 2
出力例 1Copy
5
以下の 通りが考えられます。
入力例 2Copy
10 3 -1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000 -1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
出力例 2Copy
0
入力例 3Copy
300 0 0 0 1 0 0 1
出力例 3Copy
292172978
Score : points
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 1Copy
2 2 1 1 1 2 1 3 1 2 2 2
Sample Output 1Copy
5
The following paths are possible:
Sample Input 2Copy
10 3 -1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000 -1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
Sample Output 2Copy
0
Sample Input 3Copy
300 0 0 0 1 0 0 1
Sample Output 3Copy
292172978