#AGC056F. [AGC056F] Degree Sequence in DFS Order

[AGC056F] Degree Sequence in DFS Order

Score : 16001600 points

Problem Statement

Given are integers NN and MM. Find the number of integer sequences a=(a1,a2,,aN)a=(a_1,a_2,\cdots,a_N) that can be generated as follows, modulo 998244353998244353.

  • Provide an undirected connected graph GG with NN vertices and MM edges. Here, GG may not contain self-loops, but may contain multi-edges.
  • Perform DFS on GG and let aia_i be the degree of the ii-th vertex to be visited. More accurately, execute the pseudo-code below to get aa.
a = empty array

dfs(v):
    visited[v]=True
    a.append(degree[v])
    for u in g[v]:
        if not visited[u]:
            dfs(u)

dfs(arbitrary root)

Here, the variable gg represents the graph GG as an adjacency list, where g[v]g[v] is the list of vertices adjacent to the vertex vv in arbitrary order.

For example, when N=4,M=5N=4,M=5, it is possible to generate a=(2,4,1,3)a=(2,4,1,3), by providing the graph GG as follows.

picture

Here, the numbers written on vertices represent the order they are visited in the DFS. (The DFS starts at the vertex labeled 11.) The orange arrows show the transitions in the DFS, and the numbers next to them represent the order the edges are traversed.

Constraints

  • 2NM1062 \leq N \leq M \leq 10^6
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print the answer.

2 2
1

The only possible result is a=(2,2)a=(2,2). Note that GG may have multi-edges.

3 4
9
10 20
186225754
100000 1000000
191021899