#P13949. [EC Final 2019] Travel

[EC Final 2019] Travel

Problem Description

"I'm tired of seeing the same scenery in the world." --- Philosopher Pang\textit{Philosopher Pang}

Pang\textit{Pang}'s world can be simplified as a directed graph GG with nn vertices and mm edges.

A path\textit{path} in GG is an ordered list of vertices (v0,…,vt−1)(v_0,\ldots,v_{t-1}) for some non-negative integer tt such that vivi+1v_iv_{i+1} is an edge in GG for all 0≤i<t−10\le i<t-1. A path\textit{path} can be empty in this problem.

A cycle\textit{cycle} in GG is an ordered list of distinct vertices (v0,…,vt−1)(v_0,\ldots,v_{t-1}) for some positive integer t≥2t \geq 2 such that viv(i+1) mod tv_iv_{(i+1) \bmod t} is an edge in GG for all 0≤i<t0\le i<t. All circular shifts of a cycle are considered the same.

GG satisfies the following property: Every vertex is in at most one cycle.

Given a fixed integer kk, count the number of pairs (P1,P2)(P_1,P_2) modulo 998244353998244353 such that

  • P1,P2P_1,P_2 are paths;
  • For every vertex v∈Gv\in G, vv is in P1P_1 or P2P_2;
  • Let c(P,v)c(P, v) be the number of occurrences of vv in path PP. For every vertex vv of GG, c(P1,v)+c(P2,v)≤kc(P_1,v)+c(P_2, v)\le k.

Input Format

The first line contains 33 integers nn, mm and kk ($1\le n\le 2000, 0\le m\le 4000, 0\le k\le 1000000000$).

Each of the next mm lines contains two integers aa and bb, denoting an edge from vertex aa to bb (1≤a,b≤n,a≠b1\le a, b\le n, a\neq b).

No two edges connect the same pair of vertices in the same direction.

Output Format

Output one integer --- the number of pairs (P1,P2)(P_1,P_2) modulo 998244353998244353.

2 2 1
1 2
2 1
6
2 2 2
1 2
2 1
30
3 3 3
1 2
2 1
1 3
103