A - 455

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 100 点

問題文

整数 A, B, C が与えられます。A \neq B かつ B = C であるならば Yes を、そうでないならば No を出力してください。

制約

  • 1 \leq A, B, C \leq 9
  • 入力される値はすべて整数

入力

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

A B C

出力

問題文中の指示に従って Yes, No のいずれかを出力せよ。


入力例 1

4 5 5

出力例 1

Yes

4 \neq 5 かつ 5 = 5 なので Yes を出力します。


入力例 2

1 3 7

出力例 2

No

1 \neq 3 ですが 3 = 7 ではないので No を出力します。


入力例 3

6 6 6

出力例 3

No

Score : 100 points

Problem Statement

You are given integers A, B, C. If A \neq B and B = C, output Yes; otherwise, output No.

Constraints

  • 1 \leq A, B, C \leq 9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

A B C

Output

Output Yes or No according to the instructions in the problem statement.


Sample Input 1

4 5 5

Sample Output 1

Yes

Since 4 \neq 5 and 5 = 5, output Yes.


Sample Input 2

1 3 7

Sample Output 2

No

Although 1 \neq 3, we don't have 3 = 7, so output No.


Sample Input 3

6 6 6

Sample Output 3

No
B - Is it rated?

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 100 点

問題文

現在 AtCoder で開催されている AtCoder Regular Contest (ARC) には、Div. 1 と Div. 2 の 2 種類が存在します。 ARC Div. 1 では レーティング が 1600 以上 2999 以下の人が、ARC Div. 2 ではレーティングが 1200 以上 2399 以下の人がそれぞれ Rated 対象 となります。

正整数 R, X が与えられます。

レーティングが R の人は ARC Div. X において Rated 対象ですか?

制約

  • 1\leq R \leq 4229
  • 1\leq X \leq 2
  • 入力は全て整数

入力

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

R X

出力

レーティングが R の人が ARC Div. X において Rated 対象ならば Yes を、そうでないならば No を出力せよ。


入力例 1

2000 1

出力例 1

Yes

2000 は 1600 以上 2999 以下であるため、レーティングが 2000 の人は ARC Div. 1 において Rated 対象です。


入力例 2

1000 1

出力例 2

No

1000 は 1600 未満であるため、レーティングが 1000 の人は ARC Div. 1 において Rated 対象ではありません。


入力例 3

1500 2

出力例 3

Yes

1500 は 1200 以上 2399 以下であるため、レーティングが 1500 の人は ARC Div. 2 において Rated 対象です。


入力例 4

2800 2

出力例 4

No

2800 は 2399 より大きいため、レーティングが 2800 の人は ARC Div. 2 において Rated 対象ではありません。

Score : 100 points

Problem Statement

AtCoder Regular Contest (ARC) currently has two divisions: Div. 1 and Div. 2. In ARC Div. 1, participants whose rating is between 1600 and 2999, inclusive, are rated. In ARC Div. 2, participants whose rating is between 1200 and 2399, inclusive, are rated.

You are given positive integers R and X.

Determine whether a person with rating R is rated in ARC Div. X.

Constraints

  • 1 \le R \le 4229
  • 1 \le X \le 2
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

R X

Output

If a person with rating R is rated in ARC Div. X, output Yes; otherwise, output No.


Sample Input 1

2000 1

Sample Output 1

Yes

Because 2000 lies between 1600 and 2999, a person with rating 2000 is rated in ARC Div. 1.


Sample Input 2

1000 1

Sample Output 2

No

Because 1000 is less than 1600, a person with rating 1000 is not rated in ARC Div. 1.


Sample Input 3

1500 2

Sample Output 3

Yes

Because 1500 lies between 1200 and 2399, a person with rating 1500 is rated in ARC Div. 2.


Sample Input 4

2800 2

Sample Output 4

No

Because 2800 exceeds 2399, a person with rating 2800 is not rated in ARC Div. 2.

C - Subscribers

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200 点

問題文

整数 N が与えられます。
以下の指示に従って N の近似値を出力してください。

  • N が 10^3-1 以下ならば、N をそのまま出力する。
  • N が 10^3 以上 10^4-1 以下ならば、N の一の位を切り捨てて出力する。
  • N が 10^4 以上 10^5-1 以下ならば、N の十の位以下を切り捨てて出力する。
  • N が 10^5 以上 10^6-1 以下ならば、N の百の位以下を切り捨てて出力する。
  • N が 10^6 以上 10^7-1 以下ならば、N の千の位以下を切り捨てて出力する。
  • N が 10^7 以上 10^8-1 以下ならば、N の一万の位以下を切り捨てて出力する。
  • N が 10^8 以上 10^9-1 以下ならば、N の十万の位以下を切り捨てて出力する。

制約

  • N は 0 以上 10^9-1 以下の整数

入力

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

N

出力

答えを出力せよ。


入力例 1

20230603

出力例 1

20200000

20230603 は 10^7 以上 10^8-1 以下です。
したがって、一万以下の位を切り捨てて 20200000 を出力します。


入力例 2

0

出力例 2

0

入力例 3

304

出力例 3

304

入力例 4

500600

出力例 4

500000

Score : 200 points

Problem Statement

You are given an integer N.
Print an approximation of N according to the following instructions.

  • If N is less than or equal to 10^3-1, print N as it is.
  • If N is between 10^3 and 10^4-1, inclusive, truncate the ones digit of N and print the result.
  • If N is between 10^4 and 10^5-1, inclusive, truncate the tens digit and all digits below it of N and print the result.
  • If N is between 10^5 and 10^6-1, inclusive, truncate the hundreds digit and all digits below it of N and print the result.
  • If N is between 10^6 and 10^7-1, inclusive, truncate the thousands digit and all digits below it of N and print the result.
  • If N is between 10^7 and 10^8-1, inclusive, truncate the ten-thousands digit and all digits below it of N and print the result.
  • If N is between 10^8 and 10^9-1, inclusive, truncate the hundred-thousands digit and all digits below it of N and print the result.

Constraints

  • N is an integer between 0 and 10^9-1, inclusive.

Input

The input is given from Standard Input in the following format:

N

Output

Print the answer.


Sample Input 1

20230603

Sample Output 1

20200000

20230603 is between 10^7 and 10^8-1 (inclusive).
Therefore, truncate the ten-thousands digit and all digits below it, and print 20200000.


Sample Input 2

0

Sample Output 2

0

Sample Input 3

304

Sample Output 3

304

Sample Input 4

500600

Sample Output 4

500000
D - Isolated Seats

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200 点

問題文

o と x からなる長さ N の文字列 S が与えられます。
N 個の椅子が左右一列に並んでおり、左から i 番目の椅子には、S の i 文字目が o ならば人が座っており、x ならば人は座っていません。
以下の条件をすべて満たす椅子は何個あるか求めてください。

  • 人が座っていない
  • 左に椅子が無い、または左の椅子に人が座っていない
  • 右に椅子が無い、または右の椅子に人が座っていない

制約

  • 1 \leq N \leq 100
  • N は整数
  • S は o と x からなる長さ N の文字列

入力

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

N  
S  

出力

答えを 1 行で出力せよ。


入力例 1

8
xxoxxxox

出力例 1

2

左から 1,5 番目の椅子のみが条件を満たします。


入力例 2

5
ooooo

出力例 2

0

入力例 3

1
x

出力例 3

1

Score : 200 points

Problem Statement

You are given a string S of length N consisting of o and x.
N chairs are arranged in a row from left to right. If the i-th character of S is o, a person is sitting in the i-th chair from the left; if it is x, no person is sitting there.
Find the number of chairs that satisfy all of the following conditions.

  • No person is sitting in it.
  • There is no chair to its left, or no person is sitting in the chair to its left.
  • There is no chair to its right, or no person is sitting in the chair to its right.

Constraints

  • 1 \leq N \leq 100
  • N is an integer.
  • S is a string of length N consisting of o and x.

Input

The input is given from Standard Input in the following format:

N  
S  

Output

Output the answer in one line.


Sample Input 1

8
xxoxxxox

Sample Output 1

2

Only the first and fifth chairs from the left satisfy the conditions.


Sample Input 2

5
ooooo

Sample Output 2

0

Sample Input 3

1
x

Sample Output 3

1
E - Not All Covered

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 300 点

問題文

AtCoder 王国には 1 から N まで番号がつけられた N 個の城壁があります。また、 M 個の砲台があります。

砲台 i は L_i 以上 R_i 以下の番号の城壁を守っています。

ある砲台を破壊すると、その砲台が守っていた城壁はその砲台により守られなくなります。

どの砲台にも守られていない城壁が存在する状態にするためには、最小で何個の砲台を破壊する必要がありますか?

制約

  • 1 \leq N \leq 10^6
  • 1 \leq M \leq 2 \times 10^5
  • 1 \leq L_i \leq R_i \leq N (1 \leq i \leq M)
  • 入力はすべて整数

入力

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

N M
L_1 R_1
L_2 R_2
 \vdots 
L_M R_M

出力

砲台に守られていない城壁が存在する状態にするために破壊する必要がある砲台の個数の最小値を出力せよ。


入力例 1

10 4
1 6
4 5
5 10
7 10

出力例 1

1

砲台 1 を破壊するとどの砲台も城壁 3 を守っていない状態になります。 また、砲台を 1 個も破壊しなければ全ての城壁がどれかの砲台に守られている状態になります。 そのため、1 を出力します。


入力例 2

5 2
1 2
3 4

出力例 2

0

どの砲台も城壁 5 を守っていないため、砲台を 1 個も破壊しないでも砲台に守られていない城壁が存在する状態になります。そのため、0 を出力します。


入力例 3

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

出力例 3

3

Score : 300 points

Problem Statement

In the AtCoder Kingdom, there are N castle walls numbered from 1 through N. There are also M turrets.

Turret i guards castle walls numbered from L_i through R_i.

When a turret is destroyed, the castle walls that were guarded by that turret are no longer guarded by that turret.

What is the minimum number of turrets that need to be destroyed so that at least one castle wall is not guarded by any turret?

Constraints

  • 1 \leq N \leq 10^6
  • 1 \leq M \leq 2 \times 10^5
  • 1 \leq L_i \leq R_i \leq N (1 \leq i \leq M)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N M
L_1 R_1
L_2 R_2
 \vdots 
L_M R_M

Output

Output the minimum number of turrets that need to be destroyed so that at least one castle wall is not guarded by any turret.


Sample Input 1

10 4
1 6
4 5
5 10
7 10

Sample Output 1

1

If turret 1 is destroyed, no turret guards castle wall 3. Also, if no turrets are destroyed, all castle walls are guarded by some turret. Therefore, output 1.


Sample Input 2

5 2
1 2
3 4

Sample Output 2

0

Since no turret guards castle wall 5, there already exists a castle wall not guarded by any turret without destroying any turrets. Therefore, output 0.


Sample Input 3

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

Sample Output 3

3
F - Inverse of Permutation

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 300 点

問題文

1,2,\dots,N が 1 回ずつ現れる長さ N の数列を「長さ N の順列」と呼びます。
長さ N の順列 P = (p_1, p_2,\dots,p_N) が与えられるので、以下の条件を満たす長さ N の順列 Q = (q_1,\dots,q_N) を出力してください。

  • 全ての i (1 \leq i \leq N) に対して Q の p_i 番目の要素が i である。

ただし、条件を満たす Q は必ずただ 1 つ存在することが証明できます。

制約

  • 1 \leq N \leq 2 \times 10^5
  • (p_1,p_2,\dots,p_N) は長さ N の順列である。
  • 入力は全て整数である。

入力

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

N
p_1 p_2 \dots p_N

出力

数列 Q を空白区切りで 1 行で出力せよ。

q_1 q_2 \dots q_N

入力例 1

3
2 3 1

出力例 1

3 1 2

以下に説明する通り、 Q=(3,1,2) は条件を満たす順列です。

  • i = 1 のとき p_i = 2, q_2 = 1
  • i = 2 のとき p_i = 3, q_3 = 2
  • i = 3 のとき p_i = 1, q_1 = 3

入力例 2

3
1 2 3

出力例 2

1 2 3

全ての i (1 \leq i \leq N) に対して p_i = i が成り立つときは P = Q になります。


入力例 3

5
5 3 2 4 1

出力例 3

5 3 2 4 1

Score : 300 points

Problem Statement

We will call a sequence of length N where each of 1,2,\dots,N occurs once as a permutation of length N.
Given a permutation of length N, P = (p_1, p_2,\dots,p_N), print a permutation of length N, Q = (q_1,\dots,q_N), that satisfies the following condition.

  • For every i (1 \leq i \leq N), the p_i-th element of Q is i.

It can be proved that there exists a unique Q that satisfies the condition.

Constraints

  • 1 \leq N \leq 2 \times 10^5
  • (p_1,p_2,\dots,p_N) is a permutation of length N (defined in Problem Statement).
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
p_1 p_2 \dots p_N

Output

Print the sequence Q in one line, with spaces in between.

q_1 q_2 \dots q_N

Sample Input 1

3
2 3 1

Sample Output 1

3 1 2

The permutation Q=(3,1,2) satisfies the condition, as follows.

  • For i = 1, we have p_i = 2, q_2 = 1.
  • For i = 2, we have p_i = 3, q_3 = 2.
  • For i = 3, we have p_i = 1, q_1 = 3.

Sample Input 2

3
1 2 3

Sample Output 2

1 2 3

If p_i = i for every i (1 \leq i \leq N), we will have P = Q.


Sample Input 3

5
5 3 2 4 1

Sample Output 3

5 3 2 4 1
G - FizzBuzz Sum Hard

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 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
H - Permute K times

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 450 点

問題文

各要素が 1 以上 N 以下である長さ N の数列 X と、長さ N の数列 A が与えられます。
A に以下の操作を K 回行った結果を出力してください。

  • B_i=A_{X_i} なる B を新たな A とする

制約

  • 入力は全て整数
  • 1 \le N \le 2 \times 10^5
  • 0 \le K \le 10^{18}
  • 1 \le X_i \le N
  • 1 \le A_i \le 2 \times 10^5

入力

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

N K
X_1 X_2 \dots X_N
A_1 A_2 \dots A_N

出力

操作後の A を A' としたとき、以下の形式で出力せよ。

A'_1 A'_2 \dots A'_N

入力例 1

7 3
5 2 6 3 1 4 6
1 2 3 5 7 9 11

出力例 1

7 2 3 5 1 9 3

この入力では X=(5,2,6,3,1,4,6) で、操作前の数列 A=(1,2,3,5,7,9,11) です。

  • 操作を 1 度行うと、数列は (7,2,9,3,1,5,9) となります。
  • 操作を 2 度行うと、数列は (1,2,5,9,7,3,5) となります。
  • 操作を 3 度行うと、数列は (7,2,3,5,1,9,3) となります。

入力例 2

4 0
3 4 1 2
4 3 2 1

出力例 2

4 3 2 1

操作が一度も行われない場合もあります。


入力例 3

9 1000000000000000000
3 7 8 5 9 3 7 4 2
9 9 8 2 4 4 3 5 3

出力例 3

3 3 3 3 3 3 3 3 3

Score : 450 points

Problem Statement

You are given a sequence X of length N where each element is between 1 and N, inclusive, and a sequence A of length N.
Print the result of performing the following operation K times on A.

  • Replace A with B such that B_i = A_{X_i}.

Constraints

  • All input values are integers.
  • 1 \le N \le 2 \times 10^5
  • 0 \le K \le 10^{18}
  • 1 \le X_i \le N
  • 1 \le A_i \le 2 \times 10^5

Input

The input is given from Standard Input in the following format:

N K
X_1 X_2 \dots X_N
A_1 A_2 \dots A_N

Output

Let A' be the sequence A after the operations. Print it in the following format:

A'_1 A'_2 \dots A'_N

Sample Input 1

7 3
5 2 6 3 1 4 6
1 2 3 5 7 9 11

Sample Output 1

7 2 3 5 1 9 3

In this input, X=(5,2,6,3,1,4,6) and the initial sequence is A=(1,2,3,5,7,9,11).

  • After one operation, the sequence is (7,2,9,3,1,5,9).
  • After two operations, the sequence is (1,2,5,9,7,3,5).
  • After three operations, the sequence is (7,2,3,5,1,9,3).

Sample Input 2

4 0
3 4 1 2
4 3 2 1

Sample Output 2

4 3 2 1

There may be cases where no operations are performed.


Sample Input 3

9 1000000000000000000
3 7 8 5 9 3 7 4 2
9 9 8 2 4 4 3 5 3

Sample Output 3

3 3 3 3 3 3 3 3 3
I - Senshuraku

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 500 点

問題文

2N 人の選手が参加する大会が行われています。 これから、それぞれの選手は 1 回試合を行います。 残る N 回の試合のうち、i 番目 (1\le i\le N) の試合では 2i-1 番目の選手と 2i 番目の選手が対戦を行います。

それぞれの試合では、対戦する 2 人の選手のうち 1 人が勝ち、もう 1 人が負けます。 どちらの選手が勝つかは試合ごとに独立に確率 \dfrac12 で決まります。

最後の N 試合が始まる前、i 番目 (1\le i\le2N) の選手は A _ i 回勝っています。 すべての試合が終わったあと、勝った回数が最も多い選手の中から一様ランダムかつこれまでの試合結果と独立に優勝選手が選ばれます。

1 番目の選手、2 番目の選手、\ldots、2N 番目の選手のそれぞれについて、優勝する確率を{}\bmod998244353 で求めてください。

確率{}\bmod{998244353} の定義

求める確率は必ず有理数になることが証明できます。 また、この問題の制約のもとでは、求める有理数を既約分数 \frac{P}{Q} で表した時、Q {{}\not\equiv{}} 0 \pmod{998244353} となることが証明できます。 よって、R \times Q \equiv P \pmod{998244353}, 0 \leq R \lt 998244353 を満たす整数 R が一意に定まります。 この R を答えてください。

制約

  • 1\le N\le2\times10 ^ 5
  • 0\le A _ i\lt2N\ (1\le i\le 2N)
  • 入力はすべて整数

入力

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

N
A _ 1 A _ 2
A _ 3 A _ 4
\vdots
A _ {2N-1} A _ {2N}

出力

1 番目の選手が優勝する確率、2 番目の選手が優勝する確率、\ldots 、2N 番目の選手が優勝する確率を、この順に空白を区切りとして 1 行に出力せよ。


入力例 1

4
1 2
3 4
2 3
1 4

出力例 1

0 0 259959467 883862188 0 967049217 0 883862188

例えば、3 番目の選手が優勝するのは次のような場合です。

  • 2 番目の試合で自分が勝ち、3 番目の試合で 5 番目の選手が勝ち、4 番目の試合で 7 番目の選手が勝った場合、\dfrac13 の確率で優勝する。
  • 2 番目の試合で自分が勝ち、3 番目の試合で 6 番目の選手が勝ち、4 番目の試合で 7 番目の選手が勝った場合、\dfrac14 の確率で優勝する。

よって、3 番目の選手が優勝する確率は \dfrac18\times\dfrac13+\dfrac18\times\dfrac14=\dfrac7{96} です。259959467\times96\equiv7\pmod{998244353} なので、3 番目の選手が優勝する確率は{}\bmod998244353 で 259959467 です。

それぞれの選手が優勝する確率は 0,0,\dfrac7{96},\dfrac{43}{96},0,\dfrac3{96},0,\dfrac{43}{96} です。 よって、0 0 259959467 883862188 0 967049217 0 883862188 を出力してください。


入力例 2

6
0 0
0 0
0 0
0 0
0 0
0 0

出力例 2

582309206 582309206 582309206 582309206 582309206 582309206 582309206 582309206 582309206 582309206 582309206 582309206

これまで誰も勝利していない場合もあります。

対称性より、どの選手が優勝する確率も \dfrac1{12} です。


入力例 3

10
18 17
16 18
18 16
16 16
17 17
16 16
17 16
17 18
16 16
17 18

出力例 3

357877533 151989635 0 357877533 357877533 0 0 0 575116994 575116994 0 0 597386855 0 151989635 357877533 0 0 151989635 357877533

Score : 500 points

Problem Statement

A tournament is being held with 2N players. From now on, each player will play exactly one match. In the remaining N matches, the i-th (1\le i\le N) match is played between the (2i-1)-th and 2i-th players.

In each match, one of the two competing players wins and the other loses. Which player wins is determined independently for each match, and each player wins with probability \dfrac12.

Before the last N matches begin, the i-th (1\le i\le2N) player has won A _ i times. After all matches are over, the champion is chosen from among the players with the most wins, uniformly at random and independently of the previous match results.

For each of the first, second, \ldots, 2N-th players, find the probability, modulo 998244353, of that player becoming the champion.

Definition of probability modulo 998244353

It can be proved that the sought probability is always a rational number. Moreover, under the constraints of this problem, it can be proved that when the rational number is expressed as an irreducible fraction \frac{P}{Q}, we have Q {{}\not\equiv{}} 0 \pmod{998244353}. Therefore, there is a unique integer R satisfying R \times Q \equiv P \pmod{998244353}, 0 \leq R \lt 998244353. Find this R.

Constraints

  • 1\le N\le2\times10 ^ 5
  • 0\le A _ i\lt2N\ (1\le i\le 2N)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
A _ 1 A _ 2
A _ 3 A _ 4
\vdots
A _ {2N-1} A _ {2N}

Output

Output the probability of the first player becoming the champion, the probability of the second player becoming the champion, \ldots, the probability of the 2N-th player becoming the champion, in this order, separated by spaces, on a single line.


Sample Input 1

4
1 2
3 4
2 3
1 4

Sample Output 1

0 0 259959467 883862188 0 967049217 0 883862188

For example, the third player becomes the champion in the following cases:

  • If the third player wins in the second match, the fifth player wins in the third match, and the seventh player wins in the fourth match, the third player becomes the champion with probability \dfrac13.
  • If the third player wins in the second match, the sixth player wins in the third match, and the seventh player wins in the fourth match, the third player becomes the champion with probability \dfrac14.

Thus, the probability of the third player becoming the champion is \dfrac18\times\dfrac13+\dfrac18\times\dfrac14=\dfrac7{96}. We have 259959467\times96\equiv7\pmod{998244353}, so the probability of the third player becoming the champion in modulo-998244353 expression is 259959467.

The probability of each player becoming the champion is 0,0,\dfrac7{96},\dfrac{43}{96},0,\dfrac3{96},0,\dfrac{43}{96}. Thus, output 0 0 259959467 883862188 0 967049217 0 883862188.


Sample Input 2

6
0 0
0 0
0 0
0 0
0 0
0 0

Sample Output 2

582309206 582309206 582309206 582309206 582309206 582309206 582309206 582309206 582309206 582309206 582309206 582309206

It is possible that no one has won yet.

By symmetry, each player becomes the champion with probability \dfrac1{12}.


Sample Input 3

10
18 17
16 18
18 16
16 16
17 17
16 16
17 16
17 18
16 16
17 18

Sample Output 3

357877533 151989635 0 357877533 357877533 0 0 0 575116994 575116994 0 0 597386855 0 151989635 357877533 0 0 151989635 357877533