You are given a directed graph $G$, consisting of $N$ vertices and $M$ edges. The $i$-th edge is directed from $u_ i$ to $v_ i$.
An eulerian circuit of $G$ is a pair of sequence of vertices $(v_ 0,\ldots,v_ {M-1})$ and sequence of edges $(e_ 0,\ldots,e_ {M-1})$ satisfying following conditions.
Note that an Eulerian circuit remains an Eulerian circuit after any cyclic shift.
Find the number of Eulerian circuits of $G$, considered the same if they can be obtained from one another by a cyclic shift (in other words, the number of Eulerian circuits with $e_ 0 = 0$), and give the result modulo $998244353$.
$N$ $M$
$u_ 0$ $v_ 0$
$\vdots$
$u_ {M-1}$ $v_ {M-1}$
3 6 0 1 0 1 1 2 1 2 2 0 2 0
4
4 10 0 1 0 2 1 0 1 3 1 3 2 1 2 3 3 0 3 1 3 2
36
10 4 0 0 0 0 0 0 0 0
6
3 2 0 1 1 2
0
No. | Testdata Range | Score |
---|