#D

from collections import deque

n,m = list(map(int,input().split()))

#インデックス→各部屋番号(-1),つながってる部屋の番号を格納

graph = [[] for _ in range(n)]



for _ in range(m):

    a,b = list(map(int,input().split()))

    graph[a-1].append(b-1)

    graph[b-1].append(a-1)

    

#各部屋から1までの距離(初期値999)

bango = [-999 for _ in range(n)]

bango[0] = 0



#p->今いる部屋

p = deque()

p.append(0)



while not len(p)==0:

    x = p.pop()

    for i in graph[x]:

        if bango[i] != -999:

            pass

        else:

            p.appendleft(i)

            #i番目の部屋はxからいける

            bango[i] = x

print('Yes')

for i in range(1,n):

    print((bango[i]+1))
from collections import deque

n,m = list(map(int,input().split()))



graph = [[] for _ in range(n)]



for _ in range(m):

    a,b = list(map(int,input().split()))

    graph[a-1].append(b-1)

    graph[b-1].append(a-1)

    

#部屋から1までの距離(深さ)

dist = [-100 for _ in range(n)]

dist[0] = 0



#幅優先探索でdistを更新

#pに今いる位置を格納

p = deque()

p.append(0)



while len(p) > 0:

    now = p.pop()

    for i in graph[now]:

        if dist[i] != -100:

            continue

        p.appendleft(i)

        dist[i] = now

        

print('Yes')

for i in range(1,n):

    print((dist[i]+1))
# D
from collections import deque

n, m = list(map(int, input().split()))
# インデックス→各部屋番号(-1),つながってる部屋の番号を格納
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
# 各部屋から1までの距離(初期値999)
bango = [-999 for _ in range(n)]
bango[0] = 0
# p->今いる部屋
p = deque()
p.append(0)
while not len(p) == 0:
    x = p.pop()
    for i in graph[x]:
        if bango[i] != -999:
            pass
        else:
            p.appendleft(i)
            # i番目の部屋はxからいける
            bango[i] = x
print("Yes")
for i in range(1, n):
    print((bango[i] + 1))

from collections import deque

n, m = list(map(int, input().split()))
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
# 部屋から1までの距離(深さ)
dist = [-100 for _ in range(n)]
dist[0] = 0
# 幅優先探索でdistを更新
# pに今いる位置を格納
p = deque()
p.append(0)
while len(p) > 0:
    now = p.pop()
    for i in graph[now]:
        if dist[i] != -100:
            continue
        p.appendleft(i)
        dist[i] = now
print("Yes")
for i in range(1, n):
    print((dist[i] + 1))

-# D -# インデックス→各部屋番号(-1),つながってる部屋の番号を格納 -# 各部屋から1までの距離(初期値999) -bango = [-999 for _ in range(n)] -bango[0] = 0 -# p->今いる部屋 +# 部屋から1までの距離(深さ) +dist = [-100 for _ in range(n)] +dist[0] = 0 +# 幅優先探索でdistを更新 +# pに今いる位置を格納 -while not len(p) == 0: -    x = p.pop() -    for i in graph[x]: -        if bango[i] != -999: -            pass -        else: -            p.appendleft(i) -            # i番目の部屋はxからいける -            bango[i] = x +while len(p) > 0: +    now = p.pop() +    for i in graph[now]: +        if dist[i] != -100: +            continue +        p.appendleft(i) +        dist[i] = now -    print((bango[i] + 1)) +    print((dist[i] + 1))