Problem:
Score: 400 points

Problem Statement

There is a cave.

The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.

It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.

Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.

If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.

Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Constraints

All values in input are integers.

2 \leq N \leq 10^5

1 \leq M \leq 2 \times 10^5

1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)

A_i \neq B_i\ (1 \leq i \leq M)

One can travel between any two rooms by traversing passages.

Input

Input is given from Standard Input in the following format:

N M
A_1 B_1
:
A_M B_M

Output

If there is no way to place signposts satisfying the objective, print No.

Otherwise, print N lines. The first line should contain Yes, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.

Sample Input 1

4 4
1 2
2 3
3 4
4 2

Sample Output 1

Yes
1
2
2

If we place the signposts as described in the sample output, the following happens:

Starting in Room 2, you will reach Room 1 after traversing one passage: (2) \to 1. This is the minimum number of passages possible.

Starting in Room 3, you will reach Room 1 after traversing two passages: (3) \to 2 \to 1. This is the minimum number of passages possible.

Starting in Room 4, you will reach Room 1 after traversing two passages: (4) \to 2 \to 1. This is the minimum number of passages possible.

Thus, the objective is satisfied.

Sample Input 2

6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6

Sample Output 2

Yes
6
5
5
1
1

If there are multiple solutions, any of them will be accepted.

Solution in Python (3.8.2) (judge verdict: Runtime Error)

#まず一行目の"N M"を取得
N,M=map(int, input().split()) 

#2-M+1行目を入力する
arr_path=np.array([0,0])
#空のarrayを値0として定義した
for i in range(M):
    a,b=map(int,input().split())
    arr=np.array([a,b])
    arr_path=np.vstack([arr_path,arr])    

#もはや入れ子構造のリストを使うことにして、level_0のような表現は必要ない
#層の全体を格納するリストのリスト（index0,1,2..と引数に対応して、層0,1,2...と対応する）
class_layer=[]
class_layer.append([1])

#部屋xからの移動先を出力する関数
def transit(x):
    path=arr_path[np.any(arr_path==x, axis=1)]
    #これはいま部屋iを考えている（levelという層にある部屋）
    #pathをarrayから抽出して、その部屋から移動することを考える
    path=path[path != x]
    trans_list=path.tolist()
    return trans_list

#層構造(x層)を1上げて上の層を出力する関数を定義する
def level_up(x):
    now=class_layer[x]
    pre=[]
    if x >=1:
        pre=class_layer[x-1]
    li=[] 
    for i in now:
        for j in transit(i):
            if j in now:
                continue
            elif j in pre:
                continue
            else:
                li.append(j)
    class_layer.append(li)
    
for i in range(M):
    level_up(i)


#1つの部屋に対して、その部屋が何番目の層なのか出力する
def layer_finder(x):
    for i in range(M):
        for j in class_layer[i]:
            if j==x:
                global ans
                ans=i
                #local変数になってしまっていて、関数外でいまいちうまく使えないので、変数を置く前にglobal宣言というものをしてglobal変数にする
                break
            else:
                continue
    return ans


#部屋xが何番の矢印を示せばいいのか出力
def path_get(x):
    #部屋xは層が幾つなのか
    X=layer_dict[x-1]
    #(X-1)層の部屋番号を出力
    li1=class_layer[X-1]
    
    #部屋xからの移動先
    path=arr_path[np.any(arr_path==x, axis=1)]
    path=path[path != x]
    li2=path.tolist()
    
    #l1とl2の共通部分を出す
    #setと&を使うといいらしい!
    li_common=list(set(li1) & set(li2))
    
    print(li_common[0])
    

    
print("yes")
for i in range(2,N+1):
    path_get(i)