import sys

from collections import deque



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

G = [[] for _ in range(N)]

goal = False



for _ in range(M):

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

    G[A - 1].append(B - 1)

    G[B - 1].append(A - 1)

    if A == 1 or B == 1:

        goal = True



if goal:

    print("Yes")

else:

    print("No")

    sys.exit()



d = deque([0])

ans = [-1] * N



while d:

     q = d.popleft()

     for g in G[q]:

         if ans[g] == -1:

             ans[g] = q + 1

             d.append(g)



for i in range(1, N):

    print((ans[i]))
from collections import deque



def MI():

    return list(map(int, input().split()))



def LI():

    return list(map(int, input().split()))



N, M = MI()

room = [[] for _ in range(N)]



for _ in range(M):

    A, B = MI()

    room[A - 1].append(B - 1)

    room[B - 1].append(A - 1)



ans = [-1] * N

queue = deque([0])



while queue:

    u = queue.popleft()

    

    for r in room[u]:

        if ans[r] == -1:

            ans[r] = u + 1

            queue.append(r)



print("Yes")



for a in ans[1:]:

    print(a)
import sys
from collections import deque

N, M = list(map(int, input().split()))
G = [[] for _ in range(N)]
goal = False
for _ in range(M):
    A, B = list(map(int, input().split()))
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)
    if A == 1 or B == 1:
        goal = True
if goal:
    print("Yes")
else:
    print("No")
    sys.exit()
d = deque([0])
ans = [-1] * N
while d:
    q = d.popleft()
    for g in G[q]:
        if ans[g] == -1:
            ans[g] = q + 1
            d.append(g)
for i in range(1, N):
    print((ans[i]))

from collections import deque


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


N, M = MI()
room = [[] for _ in range(N)]
for _ in range(M):
    A, B = MI()
    room[A - 1].append(B - 1)
    room[B - 1].append(A - 1)
ans = [-1] * N
queue = deque([0])
while queue:
    u = queue.popleft()
    for r in room[u]:
        if ans[r] == -1:
            ans[r] = u + 1
            queue.append(r)
print("Yes")
for a in ans[1:]:
    print(a)

-import sys -N, M = list(map(int, input().split())) -G = [[] for _ in range(N)] -goal = False + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +N, M = MI() +room = [[] for _ in range(N)] -    A, B = list(map(int, input().split())) -    G[A - 1].append(B - 1) -    G[B - 1].append(A - 1) -    if A == 1 or B == 1: -        goal = True -if goal: -    print("Yes") -else: -    print("No") -    sys.exit() -d = deque([0]) +    A, B = MI() +    room[A - 1].append(B - 1) +    room[B - 1].append(A - 1) -while d: -    q = d.popleft() -    for g in G[q]: -        if ans[g] == -1: -            ans[g] = q + 1 -            d.append(g) -for i in range(1, N): -    print((ans[i])) +queue = deque([0]) +while queue: +    u = queue.popleft() +    for r in room[u]: +        if ans[r] == -1: +            ans[r] = u + 1 +            queue.append(r) +print("Yes") +for a in ans[1:]: +    print(a)