A - Median?

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 100

問題文

整数 a, b, c が与えられます。b がこれらの整数の中央値であるかどうか判定してください。

制約

  • 1 \leq a, b, c \leq 100
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

a b c

出力

b が与えられた整数の中央値であるならば Yes、そうでないならば No と出力せよ。


入力例 1

5 3 2

出力例 1

Yes

与えられた整数を小さい順に並べると 2, 3, 5 となり、b はこれらの整数の中央値です。


入力例 2

2 5 3

出力例 2

No

b は与えられた整数の中央値ではありません。


入力例 3

100 100 100

出力例 3

Yes

Score : 100 points

Problem Statement

Given integers a, b, and c, determine if b is the median of these integers.

Constraints

  • 1 \leq a, b, c \leq 100
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

a b c

Output

If b is the median of the given integers, then print Yes; otherwise, print No.


Sample Input 1

5 3 2

Sample Output 1

Yes

The given integers are 2, 3, 5 when sorted in ascending order, of which b is the median.


Sample Input 2

2 5 3

Sample Output 2

No

b is not the median of the given integers.


Sample Input 3

100 100 100

Sample Output 3

Yes
B - Distance Between Tokens

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200

問題文

HW 列のマス目があり、そのうち二つの異なるマスに駒が置かれています。

マス目の状態は H 個の長さ W の文字列 S_1, \dots, S_H で表されます。S_{i, j} = o ならば i 行目 j 列目のマスに駒が置かれていることを、S_{i, j} = - ならばそのマスには駒が置かれていないことを表します。なお、S_{i, j} は文字列 S_ij 文字目を指します。

一方の駒をマス目の外側に出ないように上下左右の隣接するマスに動かすことを繰り返すとき、もう一方の駒と同じマスに移動させるためには最小で何回動かす必要がありますか?

制約

  • 2 \leq H, W \leq 100
  • H, W は整数
  • S_i \, (1 \leq i \leq H)o および - のみからなる長さ W の文字列
  • S_{i, j} = o となる整数 1 \leq i \leq H, 1 \leq j \leq W の組がちょうど二つ存在する

入力

入力は以下の形式で標準入力から与えられる。

H W
S_1
\vdots
S_H

出力

答えを出力せよ。


入力例 1

2 3
--o
o--

出力例 1

3

1 行目 3 列目に置かれている駒を 下 \rightarrow\rightarrow 左 と移動すると 3 回でもう一方の駒と同じマスに移動させることができます。2 回以下で移動させることはできないので、3 を出力します。


入力例 2

5 4
-o--
----
----
----
-o--

出力例 2

4

Score : 200 points

Problem Statement

There is a grid with H horizontal rows and W vertical columns, in which two distinct squares have a piece.

The state of the squares is represented by H strings S_1, \dots, S_H of length W. S_{i, j} = o means that there is a piece in the square at the i-th row from the top and j-th column from the left; S_{i, j} = - means that the square does not have a piece. Here, S_{i, j} denotes the j-th character of the string S_i.

Consider repeatedly moving one of the pieces to one of the four adjacent squares. It is not allowed to move the piece outside the grid. How many moves are required at minimum for the piece to reach the square with the other piece?

Constraints

  • 2 \leq H, W \leq 100
  • H and W are integers.
  • S_i \, (1 \leq i \leq H) is a string of length W consisting of o and -.
  • There exist exactly two pairs of integers 1 \leq i \leq H, 1 \leq j \leq W such that S_{i, j} = o.

Input

Input is given from Standard Input in the following format:

H W
S_1
\vdots
S_H

Output

Print the answer.


Sample Input 1

2 3
--o
o--

Sample Output 1

3

The piece at the 1-st row from the top and 3-rd column from the left can reach the square with the other piece in 3 moves: down, left, left. Since it is impossible to do so in two or less moves, 3 should be printed.


Sample Input 2

5 4
-o--
----
----
----
-o--

Sample Output 2

4
C - Max - Min Query

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 300

問題文

整数の多重集合 S があります。はじめ S は空です。

Q 個のクエリが与えられるので順に処理してください。 クエリは次の 3 種類のいずれかです。

  • 1 x : Sx1 個追加する。

  • 2 x c : S から x\mathrm{min}(c, (S に含まれる x の個数 )) 個削除する。

  • 3 : (S の最大値 )- (S の最小値 ) を出力する。このクエリを処理するとき、 S が空でないことが保証される。

制約

  • 1 \leq Q \leq 2\times 10^5
  • 0 \leq x \leq 10^9
  • 1 \leq c \leq Q
  • 3 のクエリを処理するとき、S は空でない。
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

Q
\mathrm{query}_1
\vdots
\mathrm{query}_Q

i 番目のクエリを表す \mathrm{query}_i は以下の 3 種類のいずれかである。

1 x
2 x c
3 

出力

3 のクエリに対する答えを順に改行区切りで出力せよ。


入力例 1

8
1 3
1 2
3
1 2
1 7
3
2 2 3
3

出力例 1

1
5
4

多重集合 S は以下のように変化します。

  • 1 番目のクエリ : S3 を追加する。S\lbrace3 \rbrace となる。
  • 2 番目のクエリ : S2 を追加する。S\lbrace2, 3\rbrace となる。
  • 3 番目のクエリ : S = \lbrace 2, 3\rbrace の最大値は 3 、最小値は 2 なので、 3-2=1 を出力する。
  • 4 番目のクエリ : S2 を追加する。S\lbrace2,2,3 \rbrace となる。
  • 5 番目のクエリ : S7 を追加する。S\lbrace2, 2,3, 7\rbrace となる。
  • 6 番目のクエリ : S = \lbrace2,2,3, 7\rbrace の最大値は 7 、最小値は 2 なので、 7-2=5 を出力する。
  • 7 番目のクエリ : S に含まれる 2 の個数は 2 個なので、 \mathrm{min(2,3)} = 2 個の 2S から削除する。S\lbrace3, 7\rbrace となる。
  • 8 番目のクエリ : S = \lbrace3, 7\rbrace の最大値は 7 、最小値は 3 なので、 7-3=4 を出力する。

入力例 2

4
1 10000
1 1000
2 100 3
1 10

出力例 2


クエリ 3 が含まれない場合、何も出力してはいけません。

Score : 300 points

Problem Statement

We have a multiset of integers S, which is initially empty.

Given Q queries, process them in order. Each query is of one of the following types.

  • 1 x: Insert an x into S.

  • 2 x c: Remove an x from S m times, where m = \mathrm{min}(c,( the number of x's contained in S)).

  • 3 : Print ( maximum value of S)-( minimum value of S). It is guaranteed that S is not empty when this query is given.

Constraints

  • 1 \leq Q \leq 2\times 10^5
  • 0 \leq x \leq 10^9
  • 1 \leq c \leq Q
  • When a query of type 3 is given, S is not empty.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

Q
\mathrm{query}_1
\vdots
\mathrm{query}_Q

\mathrm{query}_i, which denotes the i-th query, is in one of the following formats:

1 x
2 x c
3 

Output

Print the answers for the queries of type 3 in the given order, separated by newlines.


Sample Input 1

8
1 3
1 2
3
1 2
1 7
3
2 2 3
3

Sample Output 1

1
5
4

The multiset S transitions as follows.

  • 1-st query: insert 3 into S. S is now \lbrace 3 \rbrace.
  • 2-nd query: insert 2 into S. S is now \lbrace 2, 3 \rbrace.
  • 3-rd query: the maximum value of S = \lbrace 2, 3\rbrace is 3 and its minimum value is 2, so print 3-2=1.
  • 4-th query: insert 2 into S. S is now \lbrace 2,2,3 \rbrace.
  • 5-th query: insert 7 into S. S is now \lbrace 2, 2,3, 7\rbrace.
  • 6-th query: the maximum value of S = \lbrace 2,2,3, 7\rbrace is 7 and its minimum value is 2, so print 7-2=5.
  • 7-th query: since there are two 2's in S and \mathrm{min(2,3)} = 2, remove 2 from S twice. S is now \lbrace 3, 7\rbrace.
  • 8-th query: the maximum value of S = \lbrace 3, 7\rbrace is 7 and its minimum value is 3, so print 7-3=4.

Sample Input 2

4
1 10000
1 1000
2 100 3
1 10

Sample Output 2


If the given queries do not contain that of type 3, nothing should be printed.

D - FizzBuzz Sum Hard

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 400

問題文

1 以上 N 以下の整数であって、A の倍数でも B の倍数でもないものの総和を求めてください。

制約

  • 1 \leq N, A,B \leq 10^9
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N A B

出力

答えを出力せよ。


入力例 1

10 3 5

出力例 1

22

1 以上 10 以下の整数で 3 の倍数でも 5 の倍数でもないのは 1,2,4,7,8 です。それらの総和は 1+2+4+7+8 =22 です。


入力例 2

1000000000 314 159

出力例 2

495273003954006262

Score : 400 points

Problem Statement

Find the sum of integers between 1 and N (inclusive) that are not multiples of A or B.

Constraints

  • 1 \leq N, A,B \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the answer.


Sample Input 1

10 3 5

Sample Output 1

22

The integers between 1 and 10 (inclusive) that are not multiples of 3 or 5 are 1,2,4,7, and 8, whose sum is 1+2+4+7+8 =22.


Sample Input 2

1000000000 314 159

Sample Output 2

495273003954006262
E - Distance Sequence

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 500

問題文

長さ N の整数からなる数列 A=(A_1,\ldots,A_N) であって、以下の条件を全て満たすものは何通りありますか?

  • 1\le A_i \le M (1 \le i \le N)

  • |A_i - A_{i+1}| \geq K (1 \le i \le N - 1)

ただし、答えは非常に大きくなることがあるので、答えを 998244353 で割った余りを求めてください。

制約

  • 2 \leq N \leq 1000
  • 1 \leq M \leq 5000
  • 0 \leq K \leq M-1
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N M K

出力

答えを 998244353 で割った余りを出力せよ。


入力例 1

2 3 1

出力例 1

6

条件を満たす数列は以下の 6 つです。

  • (1,2)
  • (1,3)
  • (2,1)
  • (2,3)
  • (3,1)
  • (3,2)

入力例 2

3 3 2

出力例 2

2

条件を満たす数列は以下の 2 つです。

  • (1,3,1)
  • (3,1,3)

入力例 3

100 1000 500

出力例 3

657064711

答えを 998244353 で割った余りを出力してください。

Score : 500 points

Problem Statement

How many integer sequences A=(A_1,\ldots,A_N) of length N satisfy all the conditions below?

  • 1\le A_i \le M (1 \le i \le N)

  • |A_i - A_{i+1}| \geq K (1 \le i \le N - 1)

Since the count can be enormous, find it modulo 998244353.

Constraints

  • 2 \leq N \leq 1000
  • 1 \leq M \leq 5000
  • 0 \leq K \leq M-1
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M K

Output

Print the count modulo 998244353.


Sample Input 1

2 3 1

Sample Output 1

6

The following 6 sequences satisfy the conditions.

  • (1,2)
  • (1,3)
  • (2,1)
  • (2,3)
  • (3,1)
  • (3,2)

Sample Input 2

3 3 2

Sample Output 2

2

The following 2 sequences satisfy the conditions.

  • (1,3,1)
  • (3,1,3)

Sample Input 3

100 1000 500

Sample Output 3

657064711

Print the count modulo 998244353.

F - Operations on a Matrix

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 500

問題文

N 行、横 M 列の行列があり、はじめ全ての成分は 0 です。

以下のいずれかの形式で表されるクエリを Q 個処理してください。

  • 1 l r x : l 列目、l+1 列目、\ldotsr 列目の成分全てに x を足す。
  • 2 i x : i 行目の成分全てを x で置き換える。
  • 3 i j : (i, j) 成分を出力する。

制約

  • 1 \leq N, M, Q \leq 2 \times 10^5
  • 1 l r x の形式のクエリについて、1 \leq l \leq r \leq M かつ 1 \leq x \leq 10^9
  • 2 i x の形式のクエリについて、1 \leq i \leq N かつ 1 \leq x \leq 10^9
  • 3 i j の形式にクエリについて、1 \leq i \leq N かつ 1 \leq j \leq M
  • 3 i j の形式のクエリが一個以上与えられる
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N M Q
\mathrm{Query}_1
\vdots
\mathrm{Query}_Q

i 番目に与えられるクエリを表す \mathrm{Query}_i は以下のいずれかの形式である。

1 l r x
2 i x
3 i j

出力

3 i j の形式の各クエリについて、答えを一行に出力せよ。


入力例 1

3 3 9
1 1 2 1
3 2 2
2 3 2
3 3 3
3 3 1
1 2 3 3
3 3 2
3 2 3
3 1 2

出力例 1

1
2
2
5
3
4

行列は次のように変化します。

\begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 1 & 1 & 0 \\ 1 & 1 & 0 \\ 1 & 1 & 0 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 1 & 1 & 0 \\ 1 & 1 & 0 \\ 2 & 2 & 2 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 1 & 4 & 3 \\ 1 & 4 & 3 \\ 2 & 5 & 5 \\ \end{pmatrix}


入力例 2

1 1 10
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
3 1 1

出力例 2

9000000000

入力例 3

10 10 10
1 1 8 5
2 2 6
3 2 1
3 4 7
1 5 9 7
3 3 2
3 2 8
2 8 10
3 8 8
3 1 10

出力例 3

6
5
5
13
10
0

Score : 500 points

Problem Statement

We have an N \times M matrix, whose elements are initially all 0.

Process Q given queries. Each query is in one of the following formats.

  • 1 l r x : Add x to every element in the l-th, (l+1)-th, \ldots, and r-th column.
  • 2 i x: Replace every element in the i-th row with x.
  • 3 i j: Print the (i, j)-th element.

Constraints

  • 1 \leq N, M, Q \leq 2 \times 10^5
  • Every query is in one of the formats listed in the Problem Statement.
  • For each query in the format 1 l r x, 1 \leq l \leq r \leq M and 1 \leq x \leq 10^9.
  • For each query in the format 2 i x, 1 \leq i \leq N and 1 \leq x \leq 10^9.
  • For each query in the format 3 i j, 1 \leq i \leq N and 1 \leq j \leq M.
  • At least one query in the format 3 i j is given.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M Q
\mathrm{Query}_1
\vdots
\mathrm{Query}_Q

\mathrm{Query}_i, which denotes the i-th query, is in one of the following formats:

1 l r x
2 i x
3 i j

Output

For each query in the format 3 i j, print a single line containing the answer.


Sample Input 1

3 3 9
1 1 2 1
3 2 2
2 3 2
3 3 3
3 3 1
1 2 3 3
3 3 2
3 2 3
3 1 2

Sample Output 1

1
2
2
5
3
4

The matrix transitions as follows.

\begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 1 & 1 & 0 \\ 1 & 1 & 0 \\ 1 & 1 & 0 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 1 & 1 & 0 \\ 1 & 1 & 0 \\ 2 & 2 & 2 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 1 & 4 & 3 \\ 1 & 4 & 3 \\ 2 & 5 & 5 \\ \end{pmatrix}


Sample Input 2

1 1 10
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
3 1 1

Sample Output 2

9000000000

Sample Input 3

10 10 10
1 1 8 5
2 2 6
3 2 1
3 4 7
1 5 9 7
3 3 2
3 2 8
2 8 10
3 8 8
3 1 10

Sample Output 3

6
5
5
13
10
0
G - Swap Many Times

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 600

問題文

2 以上の整数 N に対し、1 \leq x \lt y \leq N を満たす整数の組 (x, y)\frac{N(N - 1)}{2} 個あります。

これらを辞書順で小さい順に並べたもののうち L 番目、L+1 番目、\ldotsR 番目のものをそれぞれ (x_1, y_1), \dots, (x_{R - L + 1}, y_{R - L + 1}) とおきます。数列 A = (1, \dots, N) に対し、i = 1, \dots, R-L+1 の順に以下の操作を行います。

  • A_{x_i}A_{y_i} を入れ替える

操作後の A を求めてください。

なお、(a, b)(c, d) よりも辞書順で小さいとは、以下のいずれかが成り立つことをいいます。

  • a \lt c
  • a = c かつ b \lt d

制約

  • 2 \leq N \leq 2 \times 10^5
  • 1 \leq L \leq R \leq \frac{N(N-1)}{2}
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N L R

出力

操作後の A の各項を空白区切りで一行に出力せよ。


入力例 1

5 3 6

出力例 1

5 1 2 3 4

1 \leq x \lt y \leq N を満たす整数の組を辞書順で小さい順に並べたもののうち 3, 4, 5, 6 番目のものはそれぞれ (1, 4), (1, 5), (2, 3), (2, 4) です。

これらについて順に操作を行うと、A は次のように変化します。

(1, 2, 3, 4, 5) \rightarrow (4, 2, 3, 1, 5) \rightarrow (5, 2, 3, 1, 4) \rightarrow (5, 3, 2, 1, 4) \rightarrow (5, 1, 2, 3, 4)


入力例 2

10 12 36

出力例 2

1 10 9 8 7 4 3 2 5 6

Score : 600 points

Problem Statement

For an integer N greater than or equal to 2, there are \frac{N(N - 1)}{2} pairs of integers (x, y) such that 1 \leq x \lt y \leq N.

Consider the sequence of these pairs sorted in the increasing lexicographical order. Let (x_1, y_1), \dots, (x_{R - L + 1}, y_{R - L + 1}) be its L-th, (L+1)-th, \ldots, and R-th elements, respectively. On a sequence A = (1, \dots, N), We will perform the following operation for i = 1, \dots, R-L+1 in this order:

  • Swap A_{x_i} and A_{y_i}.

Find the final A after all the operations.

We say that (a, b) is smaller than (c, d) in the lexicographical order if and only if one of the following holds:

  • a \lt c
  • a = c and b \lt d

Constraints

  • 2 \leq N \leq 2 \times 10^5
  • 1 \leq L \leq R \leq \frac{N(N-1)}{2}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N L R

Output

Print the terms of A after all the operations in one line, separated by spaces.


Sample Input 1

5 3 6

Sample Output 1

5 1 2 3 4

Consider the sequence of pairs of integers such that 1 \leq x \lt y \leq N sorted in the increasing lexicographical order. Its 3-rd, 4-th, 5-th, and 6-th elements are (1, 4), (1, 5), (2, 3), (2, 4), respectively.

Corresponding to these pairs, A transitions as follows.

(1, 2, 3, 4, 5) \rightarrow (4, 2, 3, 1, 5) \rightarrow (5, 2, 3, 1, 4) \rightarrow (5, 3, 2, 1, 4) \rightarrow (5, 1, 2, 3, 4)


Sample Input 2

10 12 36

Sample Output 2

1 10 9 8 7 4 3 2 5 6
Ex - We Love Forest

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 600

問題文

頂点に 1 から N の番号がついた N 頂点 0 辺のグラフ G があります。また、長さ M の数列 u=(u_1,u_2,\ldots,u_M),v=(v_1,v_2,\ldots,v_M) が与えられます。

あなたは以下の操作を N-1 回行います。

  • i (1 \leq i \leq M) を一様ランダムに選ぶ。 G に頂点 u_i と頂点 v_i を結ぶ無向辺を追加する。

すでに Gu_iv_i を結ぶ辺があった場合も、新たに辺を追加する操作を行うことに注意してください。すなわち、操作後の G には多重辺が存在する可能性があります。

K=1,2,\ldots,N-1 について、K 回の操作後に G が森になっている確率を \bmod 998244353 で求めてください。

森とは?

閉路を含まない無向グラフのことを森と呼びます。森は連結でなくても構いません。

確率 \bmod 998244353 の定義

この問題で求める確率は必ず有理数になることが証明できます。 また、この問題の制約下では、求める確率を既約分数 \frac{y}{x} で表したときに x998244353 で割り切れないことが保証されます。

このとき xz \equiv y \pmod{998244353} を満たすような 0 以上 998244352 以下の整数 z が一意に定まります。この z を答えてください。

制約

  • 2 \leq N \leq 14
  • N-1 \leq M \leq 500
  • 1 \leq u_i,v_i \leq N
  • u_i\neq v_i
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N M
u_1 v_1
\vdots
u_M v_M

出力

N-1 行出力せよ。i 行目には i 回の操作後に G が森になっている確率を \bmod 998244353 で出力せよ。


入力例 1

3 2
1 2
2 3

出力例 1

1
499122177

頂点 u と頂点 v を結ぶ辺を (u,v) と書きます。

操作を 1 回行った後の G は以下のようになります。

  • 1/2 の確率で、辺 (1, 2) が存在する。
  • 1/2 の確率で、辺 (2, 3) が存在する。

どちらの場合も G は森なので、 K=1 の場合の答えは 1 です。

操作を 2 回行った後の G は以下のようになります。

  • 1/4 の確率で、辺 (1, 2),(1,2) が存在する。
  • 1/4 の確率で、辺 (2, 3),(2,3) が存在する。
  • 1/2 の確率で、辺 (1, 2),(2,3) が存在する。

(1,2),(2,3) が存在するときのみ G は森となっています。よって求める確率は 1/2 であり、これを \bmod 998244353 で表した 499122177 を出力してください。


入力例 2

4 5
1 2
1 2
1 4
2 3
2 4

出力例 2

1
758665709
918384805

Score : 600 points

Problem Statement

We have a graph G with N vertices numbered 1 through N and 0 edges. You are given sequences u=(u_1,u_2,\ldots,u_M),v=(v_1,v_2,\ldots,v_M) of length M.

You will perform the following operation (N-1) times.

  • Choose i (1 \leq i \leq M) uniformly at random. Add to G an undirected edge connecting Vertices u_i and v_i.

Note that the operation above will add a new edge connecting Vertices u_i and v_i even if G already has one or more edges between them. In other words, the resulting G may contain multiple edges.

For each K=1,2,\ldots,N-1, find the probability, modulo 998244353, that G is a forest after the K-th operation.

What is a forest?

An undirected graph without a cycle is called a forest. A forest is not necessarily connected.

Definition of probability modulo 998244353

We can prove that the sought probability is always a rational number. Moreover, under the Constraints of this problem, it is guaranteed that, when the sought probability is represented by an irreducible fraction \frac{y}{x}, x is indivisible by 998244353.

Then, we can uniquely determine an integer z between 0 and 998244352 (inclusive) such that xz \equiv y \pmod{998244353}. Print this z.

Constraints

  • 2 \leq N \leq 14
  • N-1 \leq M \leq 500
  • 1 \leq u_i,v_i \leq N
  • u_i\neq v_i
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
u_1 v_1
\vdots
u_M v_M

Output

Print N-1 lines. The i-th line should contain the probability, modulo 998244353, that G is a forest after the i-th operation.


Sample Input 1

3 2
1 2
2 3

Sample Output 1

1
499122177

Let us denote by (u, v) the edge connecting Vertices u and v.

After the 1-st operation, G will have:

  • Edge (1, 2) with a probability of 1/2;
  • Edge (2, 3) with a probability of 1/2.

In both cases, G is a forest, so the answer for K=1 is 1.

After the 2-nd operation, G will have:

  • Edges (1, 2) and (1, 2) with a probability of 1/4;
  • Edges (2, 3) and (2, 3) with a probability of 1/4;
  • Edges (1, 2) and (2, 3) with a probability of 1/2.

G is a forest only when G has Edges (1, 2) and (2, 3). Therefore, the sought probability is 1/2; when represented modulo 998244353, it is 499122177, which should be printed.


Sample Input 2

4 5
1 2
1 2
1 4
2 3
2 4

Sample Output 2

1
758665709
918384805