This page is still under construction.

Parts of this page are still being built. What you see may change.

Travel

Time limit2.5sMemory limit256 MB

Summary
Count pairs of paths covering every vertex of a directed graph with at most one cycle per vertex, each vertex used at most k times in total, mod 998244353.
Level

Hard9 of 10

Topics
Graph, Dynamic programming, Combinatorics
Solved
No attempts yet

Problem

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

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

A 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 can be empty.

A cycle in GG is an ordered list of distinct vertices (v0,…,vt−1)(v_0,\ldots,v_{t-1}) for some 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:

  1. P1P_1 and P2P_2 are paths.
  2. For every vertex v∈Gv\in G, vv is in P1P_1 or P2P_2.
  3. 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.

The time limit is 2500 ms and the memory limit is 256 MB.

Input

The first line contains three integers nn, mm, and kk (1≤n≤20001\le n\le 2000, 0≤m≤40000\le m\le 4000, 0≤k≤10000000000\le k\le 1000000000).

Each of the next mm lines contains two integers aa and bb, denoting an edge from vertex aa to vertex bb (1≤a,b≤n1\le a,b\le n, a≠ba\neq b). No two edges connect the same pair of vertices in the same direction.

Output

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

Examples3

  1. Example 1

    Input
    2 2 1
    1 2
    2 1
    
    Expected output
    6
    
  2. Example 2

    Input
    2 2 2
    1 2
    2 1
    
    Expected output
    30
    
  3. Example 3

    Input
    3 3 3
    1 2
    2 1
    1 3
    
    Expected output
    103