import sys

from collections import *



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

adj=defaultdict(list)

for ln in sys.stdin:

    A,B=list(map(int,ln.split()))

    A,B=A-1,B-1

    adj[A].append(B)

    adj[B].append(A)



a={0:0}

que=deque([0])

while que:

    u=que.popleft()

    for v in adj[u]:

        if v not in a:

            a[v]=u

            que.append(v)



if N-1-len(a)>0:

    print('No')

else:

    print('Yes')

    for i in range(1,N):

        print((a[i]+1))

import sys

from collections import *



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

adj=[[] for _ in range(N+1)]

for ln in sys.stdin:

    A,B=list(map(int,ln.split()))

    adj[A].append(B)

    adj[B].append(A)



ans=[0]*(N+1)

ans[1]=1

que=deque([1])

while que:

    A=que.popleft()

    for B in adj[A]:

        if ans[B]==0:

            ans[B]=A

            que.append(B)



print('Yes')

for i in range(2,N+1):

    print((ans[i]))

import sys
from collections import *

N, M = list(map(int, input().split()))
adj = defaultdict(list)
for ln in sys.stdin:
    A, B = list(map(int, ln.split()))
    A, B = A - 1, B - 1
    adj[A].append(B)
    adj[B].append(A)
a = {0: 0}
que = deque([0])
while que:
    u = que.popleft()
    for v in adj[u]:
        if v not in a:
            a[v] = u
            que.append(v)
if N - 1 - len(a) > 0:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print((a[i] + 1))

import sys
from collections import *

N, M = list(map(int, input().split()))
adj = [[] for _ in range(N + 1)]
for ln in sys.stdin:
    A, B = list(map(int, ln.split()))
    adj[A].append(B)
    adj[B].append(A)
ans = [0] * (N + 1)
ans[1] = 1
que = deque([1])
while que:
    A = que.popleft()
    for B in adj[A]:
        if ans[B] == 0:
            ans[B] = A
            que.append(B)
print("Yes")
for i in range(2, N + 1):
    print((ans[i]))

-adj = defaultdict(list) +adj = [[] for _ in range(N + 1)] -    A, B = A - 1, B - 1 -a = {0: 0} -que = deque([0]) +ans = [0] * (N + 1) +ans[1] = 1 +que = deque([1]) -    u = que.popleft() -    for v in adj[u]: -        if v not in a: -            a[v] = u -            que.append(v) -if N - 1 - len(a) > 0: -    print("No") -else: -    print("Yes") -    for i in range(1, N): -        print((a[i] + 1)) +    A = que.popleft() +    for B in adj[A]: +        if ans[B] == 0: +            ans[B] = A +            que.append(B) +print("Yes") +for i in range(2, N + 1): +    print((ans[i]))