import queue



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

hen = [[] for i in range(n)]

ans = [0 for i in range(n)]

a,b = 0,0







for i in range(m):

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

    hen[a-1].append(b)

    hen[b-1].append(a)



q = queue.Queue()

q.put(1)



while q.empty() == False:

    head = q.get()

    for h in hen[head-1]:

        if h != 1 and ans[h-1] == 0:

            ans[h-1] = head

            q.put(h)



flag = 0



for i in range(n):

    if i != 0 and ans[i] == 0:

        flag = 1



if flag == 0:

    print('Yes')

    for i in range(n-1):

        print((ans[i+1]))

else:

    print('No')

from collections import deque



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

turo = [[] for i in range(n+1)]

sirusi = [-1 for i in range(n+1)]



for i in range(m):

    tmp = list(map(int,input().split()))

    turo[tmp[0]].append(tmp[1])

    turo[tmp[1]].append(tmp[0])



sirusi[1] = 0



q = deque()

q.append(1)



while len(q) != 0:

    x = q.popleft()

    for i in turo[x]:

        if sirusi[i] == -1:

            sirusi[i] = x

            q.append(i)



print('Yes')

for i in range(n+1):

    if i != 0 and i != 1:

        print((sirusi[i]))

import queue

n, m = list(map(int, input().split()))
hen = [[] for i in range(n)]
ans = [0 for i in range(n)]
a, b = 0, 0
for i in range(m):
    a, b = list(map(int, input().split()))
    hen[a - 1].append(b)
    hen[b - 1].append(a)
q = queue.Queue()
q.put(1)
while q.empty() == False:
    head = q.get()
    for h in hen[head - 1]:
        if h != 1 and ans[h - 1] == 0:
            ans[h - 1] = head
            q.put(h)
flag = 0
for i in range(n):
    if i != 0 and ans[i] == 0:
        flag = 1
if flag == 0:
    print("Yes")
    for i in range(n - 1):
        print((ans[i + 1]))
else:
    print("No")

from collections import deque

n, m = list(map(int, input().split()))
turo = [[] for i in range(n + 1)]
sirusi = [-1 for i in range(n + 1)]
for i in range(m):
    tmp = list(map(int, input().split()))
    turo[tmp[0]].append(tmp[1])
    turo[tmp[1]].append(tmp[0])
sirusi[1] = 0
q = deque()
q.append(1)
while len(q) != 0:
    x = q.popleft()
    for i in turo[x]:
        if sirusi[i] == -1:
            sirusi[i] = x
            q.append(i)
print("Yes")
for i in range(n + 1):
    if i != 0 and i != 1:
        print((sirusi[i]))

-import queue +from collections import deque -hen = [[] for i in range(n)] -ans = [0 for i in range(n)] -a, b = 0, 0 +turo = [[] for i in range(n + 1)] +sirusi = [-1 for i in range(n + 1)] -    a, b = list(map(int, input().split())) -    hen[a - 1].append(b) -    hen[b - 1].append(a) -q = queue.Queue() -q.put(1) -while q.empty() == False: -    head = q.get() -    for h in hen[head - 1]: -        if h != 1 and ans[h - 1] == 0: -            ans[h - 1] = head -            q.put(h) -flag = 0 -for i in range(n): -    if i != 0 and ans[i] == 0: -        flag = 1 -if flag == 0: -    print("Yes") -    for i in range(n - 1): -        print((ans[i + 1])) -else: -    print("No") +    tmp = list(map(int, input().split())) +    turo[tmp[0]].append(tmp[1]) +    turo[tmp[1]].append(tmp[0]) +sirusi[1] = 0 +q = deque() +q.append(1) +while len(q) != 0: +    x = q.popleft() +    for i in turo[x]: +        if sirusi[i] == -1: +            sirusi[i] = x +            q.append(i) +print("Yes") +for i in range(n + 1): +    if i != 0 and i != 1: +        print((sirusi[i]))