Problem Statement There is a simple directed graph G with N vertices and N+M edges. The…
- User
Problem Statement There is a simple directed graph G with N vertices and N+M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to N+M.
Edge i goes from vertex i to vertex i+1. (Here, vertex N+1 is considered as vertex 1.) Edge N+i (1≤i≤M) goes from vertex X i to vertex Y i .
Takahashi is at vertex
- 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 K times.
That is, find the number of integer sequences (v 0 ,v 1 ,…,v K ) of length K+1 satisfying all of the following three conditions:
1≤v i ≤N for i=0,1,…,K. v 0 =1. There is a directed edge from vertex v i−1 to vertex v i for i=1,2,…,K. Since this number can be very large, print it modulo 998244353.
Constraints 2≤N≤2×10 5
0≤M≤50 1≤K≤2×10 5
1≤X i ,Y i ≤N, X i
=Y i
All of the N+M directed edges are distinct. All input values are integers. Input The input is given from Standard Input in the following format:
N M K X 1
Y 1
X 2
Y 2
⋮ X M
Y M
Output Print the count modulo 998244353.
Sample Input 1 Copy 6 2 5 1 4 2 5 Sample Output 1 Copy 5 sample1
The above figure represents the graph G. There are five ways for Takahashi to move:
Vertex 1→ Vertex 2→ Vertex 3→ Vertex 4→ Vertex 5→ Vertex 6 Vertex 1→ Vertex 2→ Vertex 5→ Vertex 6→ Vertex 1→ Vertex 2 Vertex 1→ Vertex 2→ Vertex 5→ Vertex 6→ Vertex 1→ Vertex 4 Vertex 1→ Vertex 4→ Vertex 5→ Vertex 6→ Vertex 1→ Vertex 2 Vertex 1→ Vertex 4→ Vertex 5→ Vertex 6→ Vertex 1→ Vertex 4 Sample Input 2 Copy 10 0 200000 Sample Output 2 Copy 1 Sample Input 3 Copy 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 Copy 451022766
- Assistant