

#Dequeを用いたBFS

from collections import deque



N,M = list(map(int,input().split()))



r = [[] for i in range(N+1)] #ノードの初期化



for i in range(M):

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

    r[a].append(b)

    r[b].append(a)



miteru = deque([1]) #見てる要素

mita = {1} #見た要素

res = [-1]*(N+1)



while  miteru: 

    now = miteru.popleft()

    x =set( r[now])

    x = x - mita

    for i in x:

        miteru.append(i)

        if res[i] == -1:res[i] =now

        mita.add(i)

    

print("Yes")

for i in res[2:]:

    print(i)

#print("\n".join(res))



import sys



input = sys.stdin.readline



#Dequeを用いたBFS

from collections import deque



N,M = list(map(int,input().split()))



r = [[] for i in range(N+1)] #ノードの初期化



for i in range(M):

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

    r[a].append(b)

    r[b].append(a)



miteru = deque([1]) #見てる要素

mita = {1} #見た要素

res = [-1]*(N+1)



while  miteru: 

    now = miteru.popleft()

    x =set( r[now])

    x = x - mita

    for i in x:

        miteru.append(i)

        if res[i] == -1:res[i] =now

        mita.add(i)

    

print("Yes")

for i in res[2:]:

    print(i)

#print("\n".join(res))

# Dequeを用いたBFS
from collections import deque

N, M = list(map(int, input().split()))
r = [[] for i in range(N + 1)]  # ノードの初期化
for i in range(M):
    a, b = list(map(int, input().split()))
    r[a].append(b)
    r[b].append(a)
miteru = deque([1])  # 見てる要素
mita = {1}  # 見た要素
res = [-1] * (N + 1)
while miteru:
    now = miteru.popleft()
    x = set(r[now])
    x = x - mita
    for i in x:
        miteru.append(i)
        if res[i] == -1:
            res[i] = now
        mita.add(i)
print("Yes")
for i in res[2:]:
    print(i)
# print("\n".join(res))

import sys

input = sys.stdin.readline
# Dequeを用いたBFS
from collections import deque

N, M = list(map(int, input().split()))
r = [[] for i in range(N + 1)]  # ノードの初期化
for i in range(M):
    a, b = list(map(int, input().split()))
    r[a].append(b)
    r[b].append(a)
miteru = deque([1])  # 見てる要素
mita = {1}  # 見た要素
res = [-1] * (N + 1)
while miteru:
    now = miteru.popleft()
    x = set(r[now])
    x = x - mita
    for i in x:
        miteru.append(i)
        if res[i] == -1:
            res[i] = now
        mita.add(i)
print("Yes")
for i in res[2:]:
    print(i)
# print("\n".join(res))

+import sys + +input = sys.stdin.readline