E - Warp Editorial /

Time Limit: 3 sec / Memory Limit: 1024 MB

配点 : 500500

問題文

22 次元平面の原点に高橋君がいます。
高橋君はこれから、ワープを NN 回繰り返します。各ワープでは、以下の 33 つのうちいずれか 11 つを行います。

  • 現在いる座標 (x,y)(x,y) から (x+A,y+B)(x+A,y+B) に移動する
  • 現在いる座標 (x,y)(x,y) から (x+C,y+D)(x+C,y+D) に移動する
  • 現在いる座標 (x,y)(x,y) から (x+E,y+F)(x+E,y+F) に移動する

平面上の MM 箇所 (X1,Y1),,(XM,YM)(X_1,Y_1),\ldots,(X_M,Y_M) には障害物があり、これらの座標に移動することはできません。

NN 回のワープによる移動経路として考えられるものは何通りですか? 998244353998244353 で割ったあまりを求めてください。

制約

  • 1N3001 \leq N \leq 300
  • 0M1050 \leq M \leq 10^5
  • 109A,B,C,D,E,F109-10^9 \leq A,B,C,D,E,F \leq 10^9
  • (A,B),(C,D),(E,F)(A,B),(C,D),(E,F) は相異なる
  • 109Xi,Yi109-10^9 \leq X_i,Y_i \leq 10^9
  • (Xi,Yi)(0,0)(X_i,Y_i)\neq(0,0)
  • (Xi,Yi)(X_i,Y_i) は相異なる
  • 入力に含まれる値は全て整数である

入力

入力は以下の形式で標準入力から与えられる。

NN MM
AA BB CC DD EE FF
X1X_1 Y1Y_1
X2X_2 Y2Y_2
\vdots
XMX_M YMY_M

出力

答えを出力せよ。


入力例 1Copy

Copy
2 2
1 1 1 2 1 3
1 2
2 2

出力例 1Copy

Copy
5

以下の 55 通りが考えられます。

  • (0,0)(1,1)(2,3)(0,0)\to(1,1)\to(2,3)
  • (0,0)(1,1)(2,4)(0,0)\to(1,1)\to(2,4)
  • (0,0)(1,3)(2,4)(0,0)\to(1,3)\to(2,4)
  • (0,0)(1,3)(2,5)(0,0)\to(1,3)\to(2,5)
  • (0,0)(1,3)(2,6)(0,0)\to(1,3)\to(2,6)

入力例 2Copy

Copy
10 3
-1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
-1000000000 -1000000000
1000000000 1000000000
-1000000000 1000000000

出力例 2Copy

Copy
0

入力例 3Copy

Copy
300 0
0 0 1 0 0 1

出力例 3Copy

Copy
292172978

Score : 500500 points

Problem Statement

Takahashi is at the origin of a two-dimensional plane.
Takahashi will repeat teleporting NN times. In each teleportation, he makes one of the following moves:

  • Move from the current coordinates (x,y)(x,y) to (x+A,y+B)(x+A,y+B)
  • Move from the current coordinates (x,y)(x,y) to (x+C,y+D)(x+C,y+D)
  • Move from the current coordinates (x,y)(x,y) to (x+E,y+F)(x+E,y+F)

There are obstacles on MM points (X1,Y1),,(XM,YM)(X_1,Y_1),\ldots,(X_M,Y_M) on the plane; he cannot teleport to these coordinates.

How many paths are there resulting from the NN teleportations? Find the count modulo 998244353998244353.

Constraints

  • 1N3001 \leq N \leq 300
  • 0M1050 \leq M \leq 10^5
  • 109A,B,C,D,E,F109-10^9 \leq A,B,C,D,E,F \leq 10^9
  • (A,B)(A,B), (C,D)(C,D), and (E,F)(E,F) are distinct.
  • 109Xi,Yi109-10^9 \leq X_i,Y_i \leq 10^9
  • (Xi,Yi)(0,0)(X_i,Y_i)\neq(0,0)
  • (Xi,Yi)(X_i,Y_i) are distinct.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM
AA BB CC DD EE FF
X1X_1 Y1Y_1
X2X_2 Y2Y_2
\vdots
XMX_M YMY_M

Output

Print the answer.


Sample Input 1Copy

Copy
2 2
1 1 1 2 1 3
1 2
2 2

Sample Output 1Copy

Copy
5

The following 55 paths are possible:

  • (0,0)(1,1)(2,3)(0,0)\to(1,1)\to(2,3)
  • (0,0)(1,1)(2,4)(0,0)\to(1,1)\to(2,4)
  • (0,0)(1,3)(2,4)(0,0)\to(1,3)\to(2,4)
  • (0,0)(1,3)(2,5)(0,0)\to(1,3)\to(2,5)
  • (0,0)(1,3)(2,6)(0,0)\to(1,3)\to(2,6)

Sample Input 2Copy

Copy
10 3
-1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
-1000000000 -1000000000
1000000000 1000000000
-1000000000 1000000000

Sample Output 2Copy

Copy
0

Sample Input 3Copy

Copy
300 0
0 0 1 0 0 1

Sample Output 3Copy

Copy
292172978


2025-04-27 (Sun)
15:47:53 +00:00