#abc372f. F - Teleporting Takahashi 2

F - Teleporting Takahashi 2

Score : 525525 points

问题陈述

存在一个简单的有向图 GG,包含 NN 个顶点和 N+MN+M 条边。顶点编号从 11NN,边编号从 11N+MN+M

ii (1iN)(1 \leq i \leq N) 从顶点 ii 指向顶点 i+1i+1。(这里,顶点 N+1N+1 被视为顶点 11。)
N+iN+i (1iM)(1 \leq i \leq M) 从顶点 XiX_i 指向顶点 YiY_i

高桥位于顶点 11。在每个顶点,他可以移动到从当前顶点有出边指向的任何顶点。

计算他恰好移动 KK 次的方式数量。

即,找出满足以下所有三个条件的整数序列 (v0,v1,,vK)(v_0, v_1, \dots, v_K) 的长度为 K+1K+1 的数量:

  • 对于 i=0,1,,Ki = 0, 1, \dots, K,有 1viN1 \leq v_i \leq N
  • v0=1v_0 = 1
  • 对于 i=1,2,,Ki = 1, 2, \ldots, K,存在一条从顶点 vi1v_{i-1} 指向顶点 viv_i 的有向边。

由于这个数字可能非常大,请打印出模 998244353998244353 的结果。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

There is a simple directed graph GG with NN vertices and N+MN+M edges. The vertices are numbered 11 to NN, and the edges are numbered 11 to N+MN+M.

Edge ii (1iN)(1 \leq i \leq N) goes from vertex ii to vertex i+1i+1. (Here, vertex N+1N+1 is considered as vertex 11.)
Edge N+iN+i (1iM)(1 \leq i \leq M) goes from vertex XiX_i to vertex YiY_i.

Takahashi is at vertex 11. At each vertex, he can move to any vertex to which there is an outgoing edge from the current vertex.

Compute the number of ways he can move exactly KK times.

That is, find the number of integer sequences (v0,v1,,vK)(v_0, v_1, \dots, v_K) of length K+1K+1 satisfying all of the following three conditions:

  • 1viN1 \leq v_i \leq N for i=0,1,,Ki = 0, 1, \dots, K.
  • v0=1v_0 = 1.
  • There is a directed edge from vertex vi1v_{i-1} to vertex viv_i for i=1,2,,Ki = 1, 2, \ldots, K.

Since this number can be very large, print it modulo 998244353998244353.

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 0M500 \leq M \leq 50
  • 1K2×1051 \leq K \leq 2 \times 10^5
  • 1Xi,YiN1 \leq X_i, Y_i \leq N, XiYiX_i \neq Y_i
  • All of the N+MN+M directed edges are distinct.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN MM KK

X1X_1 Y1Y_1

X2X_2 Y2Y_2

\vdots

XMX_M YMY_M

Output

Print the count modulo 998244353998244353.

Sample Input 1

6 2 5
1 4
2 5

Sample Output 1

5

sample1

The above figure represents the graph GG. There are five ways for Takahashi to move:

  • Vertex 11 \to Vertex 22 \to Vertex 33 \to Vertex 44 \to Vertex 55 \to Vertex 66
  • Vertex 11 \to Vertex 22 \to Vertex 55 \to Vertex 66 \to Vertex 11 \to Vertex 22
  • Vertex 11 \to Vertex 22 \to Vertex 55 \to Vertex 66 \to Vertex 11 \to Vertex 44
  • Vertex 11 \to Vertex 44 \to Vertex 55 \to Vertex 66 \to Vertex 11 \to Vertex 22
  • Vertex 11 \to Vertex 44 \to Vertex 55 \to Vertex 66 \to Vertex 11 \to Vertex 44

Sample Input 2

10 0 200000

Sample Output 2

1

Sample Input 3

199 10 1326
122 39
142 49
164 119
197 127
188 145
69 80
6 120
24 160
18 154
185 27

Sample Output 3

451022766