A - Election 2

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

AtCoder 市では市長選挙が行われています。候補者は高橋氏と青木氏です。

2 人のどちらかに投じられた有効票は N 票あり、現在開票が行われています。なお、 N は奇数です。

現在の開票作業の途中経過は高橋氏に T 票、青木氏に A 票です。

現時点で勝敗が確定しているかを判定してください。

制約

  • 1 \leq N \leq 99
  • N は奇数
  • 0 \leq T,A \leq N
  • T+A \leq N
  • 入力はすべて整数

入力

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

N T A

出力

現時点で勝敗が確定しているならば Yes 、そうでなければ No と出力せよ。


入力例 1

7 4 2

出力例 1

Yes

残りの 1 票が青木氏に入っても、高橋氏は勝利します。高橋氏の勝利が確定しているため、Yes と出力します。


入力例 2

99 12 48

出力例 2

No

現時点では青木氏が多く票を獲得していますが、高橋氏が残りの 39 票を獲得すると高橋氏が勝利します。よって、No と出力します。


入力例 3

1 0 0

出力例 3

No

Score : 100 points

Problem Statement

A mayoral election is being held in AtCoder City. The candidates are Takahashi and Aoki.

There are N valid votes cast for either of the two candidates, and the counting is currently underway. Here, N is an odd number.

The current vote count is T votes for Takahashi and A votes for Aoki.

Determine if the outcome of the election is already decided at this point.

Constraints

  • 1 \leq N \leq 99
  • N is an odd number.
  • 0 \leq T, A \leq N
  • T + A \leq N
  • All input values are integers.

Input

The input is given from standard input in the following format:

N T A

Output

Print Yes if the outcome of the election is already decided, and No otherwise.


Sample Input 1

7 4 2

Sample Output 1

Yes

Even if the remaining one vote goes to Aoki, Takahashi will still win. That is, his victory is decided, so print Yes.


Sample Input 2

99 12 48

Sample Output 2

No

Although Aoki currently has more votes, Takahashi would win if he receives the remaining 39 votes. Therefore, print No.


Sample Input 3

1 0 0

Sample Output 3

No
B - Vertical Writing

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

横書きの文章が与えられます。縦書きに直してください。空白を * で埋めてください。

N 個の、英小文字からなる文字列 S_1,S_2,\dots,S_N が与えられます。これらの文字列の長さの最大値を M とします。

以下の条件を満たす M 個の文字列 T_1,T_2,\dots,T_M を出力してください。

  • T_i は英小文字および * からなる
  • T_i の末尾は * でない
  • 1 \leq i \leq N について、次が成り立つ
    • 1 \leq j \leq |S_i| について、T_jN-i+1 文字目が存在し、T_1,T_2,\dots,T_{|S_i|} それぞれの N-i+1 文字目をこの順に連結したものは S_i と一致する
    • |S_i| + 1 \leq j \leq M について、T_jN-i+1 文字目は存在しないか、 * である

ただし、|S_i| で文字列 S_i の長さを表します。

制約

  • N1 以上 100 以下の整数
  • S_i は長さ 1 以上 100 以下の英小文字からなる文字列

入力

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

N
S_1
S_2
\vdots
S_N

出力

答えを以下の形式で出力せよ。

T_1
T_2
\vdots
T_M

入力例 1

3
abc
de
fghi

出力例 1

fda
geb
h*c
i

T_32 文字目を * とすることで、 c が正しい位置に来ます。 T_42,3 文字目を * とした場合、T_4 の末尾が * となり、条件を満たしません。


入力例 2

3
atcoder
beginner
contest

出力例 2

cba
oet
ngc
tio
end
sne
ter
*r

Score : 200 points

Problem Statement

You are given a horizontally written text. Convert it to vertical writing, filling spaces with *.

You are given N strings S_1, S_2, \dots, S_N consisting of lowercase English letters. Let M be the maximum length of these strings.

Print M strings T_1, T_2, \dots, T_M that satisfy the following conditions:

  • Each T_i consists of lowercase English letters and *.
  • Each T_i does not end with *.
  • For each 1 \leq i \leq N, the following holds:
    • For each 1 \leq j \leq |S_i|, the (N-i+1)-th character of T_j exists, and the concatenation of the (N-i+1)-th characters of T_1, T_2, \dots, T_{|S_i|} in this order equals S_i.
    • For each |S_i| + 1 \leq j \leq M, the (N-i+1)-th character of T_j either does not exist or is *.

Here, |S_i| denotes the length of the string S_i.

Constraints

  • N is an integer between 1 and 100, inclusive.
  • Each S_i is a string of lowercase English letters with length between 1 and 100, inclusive.

Input

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

N
S_1
S_2
\vdots
S_N

Output

Print the answer in the following format:

T_1
T_2
\vdots
T_M

Sample Input 1

3
abc
de
fghi

Sample Output 1

fda
geb
h*c
i

Placing * as the 2nd character of T_3 puts the c in the correct position. On the other hand, placing * as the 2nd and 3rd characters of T_4 would make T_4 end with *, which violates the condition.


Sample Input 2

3
atcoder
beginner
contest

Sample Output 2

cba
oet
ngc
tio
end
sne
ter
*r
C - Balls and Bag Query

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

空の袋があります。 クエリが Q 個与えられるので、順番に処理してください。

クエリは次の 3 種類です。

  • 1 x : 整数 x が書かれたボールを 1 つ袋に入れる。
  • 2 x : 整数 x が書かれたボールを 1 つ袋の中から取り出して外に捨てる。このクエリが与えられるとき、袋の中に整数 x が書かれたボールが存在することが保証される。
  • 3 : 袋の中にあるボールに書かれている整数の種類数を出力する。

制約

  • 1 \leq Q \leq 2 \times 10^{5}
  • 1 \leq x \leq 10^{6}
  • 2 種類目のクエリが与えられるとき、袋の中に整数 x が書かれたボールが存在する。
  • 3 種類目のクエリが 1 つ以上存在する。
  • 入力はすべて整数

入力

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

Q
\text{query}_1
\text{query}_2
\vdots
\text{query}_Q

i 番目のクエリ \text{query}_i は以下の 3 つの形式のいずれかで与えられる。

1 x
2 x
3

出力

3 種類目のクエリが K 個あるとき、K 行出力せよ。 i 行目(1 \leq i \leq K) では、i 番目の 3 種類目のクエリに対する答えを出力せよ。


入力例 1

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

出力例 1

3
2
3

はじめ、袋の中は空です。

1 番目のクエリ 1 3 で袋の中に 3 が書かれたボールが 1 つ入ります。

2 番目のクエリ 1 1 で袋の中に 1 が書かれたボールが 1 つ入ります。

3 番目のクエリ 1 4 で袋の中に 4 が書かれたボールが 1 つ入ります。

4 番目のクエリ 3 で袋の中に 1, 3, 43 種類のボールが入っているため、3 を出力します。

5 番目のクエリ 2 1 で袋の中から 1 が書かれたボールを 1 つ取り出します。

6 番目のクエリ 3 で袋の中に 3, 42 種類のボールが入っているため、2 を出力します。

7 番目のクエリ 1 5 で袋の中に 5 が書かれたボールが 1 つ入ります。

8 番目のクエリ 3 で袋の中に 3, 4, 53 種類のボールが入っているため、3 を出力します。


入力例 2

8
1 2
1 2
3
2 2
1 4
1 4
2 2
3

出力例 2

1
1

Score : 300 points

Problem Statement

You have an empty bag. You are given Q queries, which must be processed in order.

There are three types of queries.

  • 1 x : Put one ball with the integer x written on it into the bag.
  • 2 x : Remove one ball with the integer x written on it from the bag and discard it. It is guaranteed that the bag has a ball with the integer x written on it when this query is given.
  • 3 : Print the number of different integers written on the balls in the bag.

Constraints

  • 1 \leq Q \leq 2 \times 10^{5}
  • 1 \leq x \leq 10^{6}
  • When a query of the second type is given, the bag has a ball with the integer x written on it.
  • There is at least one query of the third type.
  • All input values are integers.

Input

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

Q
\text{query}_1
\text{query}_2
\vdots
\text{query}_Q

The i-th query \text{query}_i is given in one of the following three formats:

1 x
2 x
3

Output

If there are K queries of the third type, print K lines. The i-th line (1 \leq i \leq K) should contain the answer to the i-th query of the third type.


Sample Input 1

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

Sample Output 1

3
2
3

Initially, the bag is empty.

For the first query 1 3, a ball with the integer 3 written on it enters the bag.

For the second query 1 1, a ball with the integer 1 written on it enters the bag.

For the third query 1 4, a ball with the integer 4 written on it enters the bag.

For the fourth query 3, the bag has balls with the integers 1, 3, 4, so print 3.

For the fifth query 2 1, a ball with the integer 1 written on it is removed from the bag.

For the sixth query 3, the bag has balls with the integers 3, 4, so print 2.

For the seventh query 1 5, a ball with the integer 5 written on it enters the bag.

For the eighth query 3, the bag has balls with the integers 3, 4, 5, so print 3.


Sample Input 2

8
1 2
1 2
3
2 2
1 4
1 4
2 2
3

Sample Output 2

1
1
D - Cuboid Sum Query

Time Limit: 3 sec / Memory Limit: 1024 MiB

配点 : 400

問題文

正整数 N と、 1 \leq x,y,z \leq N を満たす整数の組 (x,y,z) に対して、整数 A_{x,y,z} が与えられます。

次の形式の Q 個のクエリが与えられるので、それぞれに答えてください。

i 個目 (1 \leq i \leq Q) のクエリでは 1 \leq Lx_i \leq Rx_i \leq N, 1 \leq Ly_i \leq Ry_i \leq N,1 \leq Lz_i \leq Rz_i \leq N をすべて満たす整数の組 (Lx_i, Rx_i, Ly_i, Ry_i, Lz_i, Rz_i) が与えられるので、

\displaystyle{\sum_{x=Lx_i}^{Rx_i} \sum_{y=Ly_i}^{Ry_i} \sum_{z=Lz_i}^{Rz_i} A_{x,y,z}}

を求めてください。

制約

  • 1 \leq N \leq 100
  • 1 \leq Q \leq 2 \times 10^{5}
  • 0 \leq A_{x,y,z} \leq 999 (1 \leq x,y,z \leq N)
  • 1 \leq Lx_i \leq Rx_i \leq N (1 \leq i \leq Q)
  • 1 \leq Ly_i \leq Ry_i \leq N (1 \leq i \leq Q)
  • 1 \leq Lz_i \leq Rz_i \leq N (1 \leq i \leq Q)
  • 入力はすべて整数

入力

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

N
A_{1,1,1} A_{1,1,2} \ldots A_{1,1,N}
A_{1,2,1} A_{1,2,2} \ldots A_{1,2,N}
\vdots
A_{1,N,1} A_{1,N,2} \ldots A_{1,N,N}
A_{2,1,1} A_{2,1,2} \ldots A_{2,1,N}
A_{2,2,1} A_{2,2,2} \ldots A_{2,2,N}
\vdots
A_{2,N,1} A_{2,N,2} \ldots A_{2,N,N}
\vdots
A_{N,1,1} A_{N,1,2} \ldots A_{N,1,N}
A_{N,2,1} A_{N,2,2} \ldots A_{N,2,N}
\vdots
A_{N,N,1} A_{N,N,2} \ldots A_{N,N,N}
Q
Lx_1 Rx_1 Ly_1 Ry_1 Lz_1 Rz_1
Lx_2 Rx_2 Ly_2 Ry_2 Lz_2 Rz_2
\vdots
Lx_Q Rx_Q Ly_Q Ry_Q Lz_Q Rz_Q

出力

Q 行出力せよ。 i 行目には i 個目のクエリに対する答えを出力せよ。


入力例 1

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

出力例 1

10
26

1 個目のクエリについて、求めるべき値は A_{1,2,1}+A_{2,2,1}=3+7=10 です。よって、10 を出力します。

2 個目のクエリについて、求めるべき値は A_{2,1,1}+A_{2,1,2}+A_{2,2,1}+A_{2,2,2}=5+6+7+8=26 です。よって、26 を出力します。


入力例 2

3
733 857 714
956 208 257
123 719 648
840 881 245
245 112 746
306 942 694
58 870 849
13 208 789
687 906 783
8
3 3 3 3 1 1
1 3 2 3 3 3
2 2 2 3 1 1
1 3 1 1 1 1
2 3 2 3 2 3
1 2 1 1 1 2
3 3 2 2 1 3
1 2 2 3 2 3

出力例 2

687
3917
551
1631
5180
3311
1010
4326

Score : 400 points

Problem Statement

You are given a positive integer N, and an integer A_{x,y,z} for each triple of integers (x, y, z) such that 1 \leq x, y, z \leq N.

You will be given Q queries in the following format, which must be processed in order.

For the i-th query (1 \leq i \leq Q), you are given a tuple of integers (Lx_i, Rx_i, Ly_i, Ry_i, Lz_i, Rz_i) such that 1 \leq Lx_i \leq Rx_i \leq N, 1 \leq Ly_i \leq Ry_i \leq N, and 1 \leq Lz_i \leq Rz_i \leq N. Find:

\displaystyle{\sum_{x=Lx_i}^{Rx_i} \sum_{y=Ly_i}^{Ry_i} \sum_{z=Lz_i}^{Rz_i} A_{x,y,z}}.

Constraints

  • 1 \leq N \leq 100
  • 1 \leq Q \leq 2 \times 10^{5}
  • 0 \leq A_{x,y,z} \leq 999 (1 \leq x, y, z \leq N)
  • 1 \leq Lx_i \leq Rx_i \leq N (1 \leq i \leq Q)
  • 1 \leq Ly_i \leq Ry_i \leq N (1 \leq i \leq Q)
  • 1 \leq Lz_i \leq Rz_i \leq N (1 \leq i \leq Q)
  • All input values are integers.

Input

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

N
A_{1,1,1} A_{1,1,2} \ldots A_{1,1,N}
A_{1,2,1} A_{1,2,2} \ldots A_{1,2,N}
\vdots
A_{1,N,1} A_{1,N,2} \ldots A_{1,N,N}
A_{2,1,1} A_{2,1,2} \ldots A_{2,1,N}
A_{2,2,1} A_{2,2,2} \ldots A_{2,2,N}
\vdots
A_{2,N,1} A_{2,N,2} \ldots A_{2,N,N}
\vdots
A_{N,1,1} A_{N,1,2} \ldots A_{N,1,N}
A_{N,2,1} A_{N,2,2} \ldots A_{N,2,N}
\vdots
A_{N,N,1} A_{N,N,2} \ldots A_{N,N,N}
Q
Lx_1 Rx_1 Ly_1 Ry_1 Lz_1 Rz_1
Lx_2 Rx_2 Ly_2 Ry_2 Lz_2 Rz_2
\vdots
Lx_Q Rx_Q Ly_Q Ry_Q Lz_Q Rz_Q

Output

Print Q lines. The i-th line should contain the answer to the i-th query.


Sample Input 1

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

Sample Output 1

10
26

For the 1st query, the sought value is A_{1,2,1} + A_{2,2,1} = 3 + 7 = 10. Thus, print 10.

For the 2nd query, the sought value is A_{2,1,1} + A_{2,1,2} + A_{2,2,1} + A_{2,2,2} = 5 + 6 + 7 + 8 = 26. Thus, print 26.


Sample Input 2

3
733 857 714
956 208 257
123 719 648
840 881 245
245 112 746
306 942 694
58 870 849
13 208 789
687 906 783
8
3 3 3 3 1 1
1 3 2 3 3 3
2 2 2 3 1 1
1 3 1 1 1 1
2 3 2 3 2 3
1 2 1 1 1 2
3 3 2 2 1 3
1 2 2 3 2 3

Sample Output 2

687
3917
551
1631
5180
3311
1010
4326
E - Manhattan Multifocal Ellipse

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 475

問題文

2 次元平面上の N 個の点 (x_1,y_1),(x_2,y_2),\dots,(x_N,y_N) と、非負整数 D が与えられます。

整数の組 (x,y) であって、 \displaystyle \sum_{i=1}^N (|x-x_i|+|y-y_i|) \leq D を満たすものの個数を求めてください。

制約

  • 1 \leq N \leq 2 \times 10^5
  • 0 \leq D \leq 10^6
  • -10^6 \leq x_i, y_i \leq 10^6
  • i\neq j ならば (x_i,y_i) \neq (x_j,y_j)
  • 入力はすべて整数

入力

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

N D
x_1 y_1
x_2 y_2
\vdots
x_N y_N

出力

答えを出力せよ。


入力例 1

2 3
0 0
1 0

出力例 1

8

下図は、サンプル 1 の入力と答えを可視化したものです。青い点が入力を表します。青い点と赤い点の合計 8 点が、問題文中の条件を満たす点です。


入力例 2

2 0
0 0
2 0

出力例 2

0

入力例 3

6 100
9 -6
10 -1
2 10
-1 7
-7 5
-1 -4

出力例 3

419

Score : 475 points

Problem Statement

You are given N points (x_1, y_1), (x_2, y_2), \dots, (x_N, y_N) on a two-dimensional plane, and a non-negative integer D.

Find the number of integer pairs (x, y) such that \displaystyle \sum_{i=1}^N (|x-x_i|+|y-y_i|) \leq D.

Constraints

  • 1 \leq N \leq 2 \times 10^5
  • 0 \leq D \leq 10^6
  • -10^6 \leq x_i, y_i \leq 10^6
  • (x_i, y_i) \neq (x_j, y_j) for i \neq j.
  • All input values are integers.

Input

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

N D
x_1 y_1
x_2 y_2
\vdots
x_N y_N

Output

Print the answer.


Sample Input 1

2 3
0 0
1 0

Sample Output 1

8

The following figure visualizes the input and the answer for Sample 1. The blue points represent the input. The blue and red points, eight in total, satisfy the condition in the statement.


Sample Input 2

2 0
0 0
2 0

Sample Output 2

0

Sample Input 3

6 100
9 -6
10 -1
2 10
-1 7
-7 5
-1 -4

Sample Output 3

419
F - Maximum Composition

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 500

問題文

N 個の一次関数 f_1,f_2,\ldots,f_N が与えられます。f_i(x)=A_i x+B_i です。

1 以上 N 以下の相異なる K 個の整数からなる長さ K の数列 p=(p_1,p_2, \ldots p_K) について、f_{p_1}(f_{p_2}(\ldots f_{p_K}(1)\ldots )) としてありえる最大値を求めてください。

制約

  • 1 \leq N \leq 2 \times 10^{5}
  • 1 \leq K \leq \text{min}(N,10)
  • 1 \leq A_i,B_i \leq 50 (1 \leq i \leq N)
  • 入力はすべて整数

入力

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

N K
A_1 B_1
A_2 B_2
\vdots
A_N B_N

出力

答えを整数として出力せよ。


入力例 1

3 2
2 3
1 5
4 2

出力例 1

26

ありえるすべての p とそれに対応する f_{p_1}(f_{p_2}(1)) の値は以下の通りです。

  • p= ( 1,2 ) : f_1(f_2(1))=15
  • p= ( 1,3 ) : f_1(f_3(1))=15
  • p= ( 2,1 ) : f_2(f_1(1))=10
  • p= ( 2,3 ) : f_2(f_3(1))=11
  • p= ( 3,1 ) : f_3(f_1(1))=22
  • p= ( 3,2 ) : f_3(f_2(1))=26

よって、 26 と出力します。


入力例 2

10 3
48 40
34 22
24 37
45 40
48 31
49 44
45 40
44 6
35 22
39 28

出力例 2

216223

Score : 500 points

Problem Statement

You are given N linear functions f_1, f_2, \ldots, f_N, where f_i(x) = A_i x + B_i.

Find the maximum possible value of f_{p_1}(f_{p_2}(\ldots f_{p_K}(1) \ldots )) for a sequence p = (p_1, p_2, \ldots, p_K) of K distinct integers between 1 and N, inclusive.

Constraints

  • 1 \leq N \leq 2 \times 10^{5}
  • 1 \leq K \leq \text{min}(N,10)
  • 1 \leq A_i, B_i \leq 50 (1 \leq i \leq N)
  • All input values are integers.

Input

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

N K
A_1 B_1
A_2 B_2
\vdots
A_N B_N

Output

Print the answer as an integer.


Sample Input 1

3 2
2 3
1 5
4 2

Sample Output 1

26

Here are all possible p and the corresponding values of f_{p_1}(f_{p_2}(1)):

  • p= ( 1,2 ) : f_1(f_2(1))=15
  • p= ( 1,3 ) : f_1(f_3(1))=15
  • p= ( 2,1 ) : f_2(f_1(1))=10
  • p= ( 2,3 ) : f_2(f_3(1))=11
  • p= ( 3,1 ) : f_3(f_1(1))=22
  • p= ( 3,2 ) : f_3(f_2(1))=26

Therefore, print 26.


Sample Input 2

10 3
48 40
34 22
24 37
45 40
48 31
49 44
45 40
44 6
35 22
39 28

Sample Output 2

216223
G - XOR Neighbors

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 600

問題文

N 頂点 M 辺の単純無向グラフが与えられます。i 番目の辺は頂点 u_iv_i を双方向に結びます。

このグラフの各頂点に 1 以上 2^{60} 未満の整数を書き込む方法であって、次の条件を満たすものが存在するか判定し、存在するならば一つ構築してください。

  • 次数が 1 以上のすべての頂点 v について、隣接する頂点 (v 自身は含まない) に書き込まれている数の総 XOR が 0 となる
XOR とは 非負整数 A,B の XOR A \oplus B は、以下のように定義されます。
  • A \oplus B を二進表記した際の 2^k \, (k \geq 0) の位の数は、A,B を二進表記した際の 2^k の位の数のうち一方のみが 1 であれば 1、そうでなければ 0 である。
例えば、 3 \oplus 5 = 6 となります (二進表記すると: 011 \oplus 101=110)。
一般に k 個の整数 p_1, \dots, p_k の XOR は (\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k) と定義され、これは p_1, \dots, p_k の順番によらないことが証明できます。

制約

  • 1 \leq N \leq 60
  • 0 \leq M \leq N(N-1)/2
  • 1 \leq u_i < v_i \leq N
  • i \neq j ならば (u_i,v_i) \neq (u_j,v_j)
  • 入力はすべて整数

入力

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

N M
u_1 v_1
u_2 v_2
\vdots
u_M v_M

出力

条件を満たす整数の書き込み方が存在しないならば、Noを出力せよ。

存在するならば、頂点 v に書き込む整数を X_v として、以下の形式で出力せよ。答えが複数ある場合、どれを出力しても良い。

Yes
X_1 X_2 \dots X_N

入力例 1

3 3
1 2
1 3
2 3

出力例 1

Yes
4 4 4

他にも、(2,2,2)(3,3,3) を書き込んでも正解になります。


入力例 2

2 1
1 2

出力例 2

No

入力例 3

1 0

出力例 3

Yes
1

1 以上 2^{60} 未満のどの整数を書き込んでも正解になります。


入力例 4

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

出力例 4

Yes
12 4 4 8

Score : 600 points

Problem Statement

You are given a simple undirected graph with N vertices and M edges. The i-th edge connects vertices u_i and v_i bidirectionally.

Determine if there exists a way to write an integer between 1 and 2^{60} - 1, inclusive, on each vertex of this graph so that the following condition is satisfied:

  • For every vertex v with a degree of at least 1, the total XOR of the numbers written on its adjacent vertices (excluding v itself) is 0.
What is XOR? The XOR of two non-negative integers A and B, denoted as A \oplus B, is defined as follows:
  • In the binary representation of A \oplus B, the bit at position 2^k \, (k \geq 0) is 1 if and only if exactly one of the bits at position 2^k in the binary representations of A and B is 1. Otherwise, it is 0.
For example, 3 \oplus 5 = 6 (in binary: 011 \oplus 101 = 110).
In general, the bitwise XOR of k integers p_1, \dots, p_k is defined as (\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k). It can be proved that this is independent of the order of p_1, \dots, p_k.

Constraints

  • 1 \leq N \leq 60
  • 0 \leq M \leq N(N-1)/2
  • 1 \leq u_i < v_i \leq N
  • (u_i, v_i) \neq (u_j, v_j) for i \neq j.
  • All input values are integers.

Input

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

N M
u_1 v_1
u_2 v_2
\vdots
u_M v_M

Output

If there is no way to write integers satisfying the condition, print No.

Otherwise, let X_v be the integer written on vertex v, and print your solution in the following format. If multiple solutions exist, any of them will be accepted.

Yes
X_1 X_2 \dots X_N

Sample Input 1

3 3
1 2
1 3
2 3

Sample Output 1

Yes
4 4 4

Other acceptable solutions include writing (2,2,2) or (3,3,3).


Sample Input 2

2 1
1 2

Sample Output 2

No

Sample Input 3

1 0

Sample Output 3

Yes
1

Any integer between 1 and 2^{60} - 1 can be written.


Sample Input 4

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

Sample Output 4

Yes
12 4 4 8