1070: Warp

Memory Limit:1024 MB Time Limit:3.000 S
Judge Style:Text Compare Creator:
Submit:303 Solved:88

Description

Fantasime 在二维坐标系的原点上。

Fantasime 会重复传送 $N$ 次。每次传送,他会执行以下移动之一:

从当前坐标 $(x,y)$ 传送到 $(x+A, y+B)$。

从当前坐标 $(x,y)$ 传送到 $(x+C,y+D)$。

从当前坐标 $(x,y)$ 传送到 $(x+E,y+F)$。

在平面上有 $M$ 个障碍,分别在点 $(X_1,Y_1),\dots,(X_M,Y_M)$ 上;他不能传送到这些点。

$N$ 次传送会产生多少条不同的路径。将数量取模 $998244353$ 后输出。

Input

输入限制:

$1 \leq N \leq 300$

$0 \leq M \leq 10^5$

$-10^9 \leq A,B,C,D,E,F \leq 10^9$

$(A,B)$,$(C,D)$ 和 $(E,F)$ 都是不同的。

$-10^9 \leq X_i,Y_i \leq 10^9$

$(X_i,Y_i) \not= (0,0)$

每个 $(X_i,Y_i)$ 都是不同的。

所有输入值都是整数。

输入遵循以下格式:

$N$ $M$

$A$ $B$ $C$ $D$ $E$ $F$

$X_1$ $Y_1$

$\dots$

$X_M$ $Y_M$

Output

输出一个整数代表答案,记得取模 $998244353$。

Sample Input Copy

2 2
1 1 1 2 1 3
1 2
2 2

Sample Output Copy

5

HINT

  • lns="http://www.w3.org/1998/Math/MathML">(0,0)(1,1)(2,4)
  • lns="http://www.w3.org/1998/Math/MathML">(0,0)(1,3)(2,4)
  • lns="http://www.w3.org/1998/Math/MathML">(0,0)(1,3)(2,5)
  • lns="http://www.w3.org/1998/Math/MathML">(0,0)(1,3)(2,6)