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



to = [[] for i in range(N+1)]



dist = [100001 for i in range(N+1)]

flug = [1 for i in range(N+1)]



to[0].append(1)

dist[0] = 0

flug[0] = 0



for i in range(M):

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

    to[a].append(b)

    to[b].append(a)



q = []

q.append(0)

while (len(q) != 0):

    i = q.pop(0)

    for j in to[i]:

        if dist[j] == 100001:

            dist[j] = dist[i] +1

            flug[j] = i

            q.append(j)



print("Yes")

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

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



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

to = [[] for i in range(N+1)]

#dist = [100001 for i in range(N+1)]

flug = [0 for i in range(N+1)]



to[0].append(1)

#dist[0] = 0



for i in range(M):

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

    to[a].append(b)

    to[b].append(a)



q = deque([0])

while (len(q) != 0):

    i = q.popleft()

    for j in to[i]:

        if flug[j] == 0:

#            dist[j] = dist[i] +1

            flug[j] = i

            q.append(j)



print("Yes")

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

    print((flug[i]))

N, M = list(map(int, input().split()))
to = [[] for i in range(N + 1)]
dist = [100001 for i in range(N + 1)]
flug = [1 for i in range(N + 1)]
to[0].append(1)
dist[0] = 0
flug[0] = 0
for i in range(M):
    a, b = list(map(int, input().split()))
    to[a].append(b)
    to[b].append(a)
q = []
q.append(0)
while len(q) != 0:
    i = q.pop(0)
    for j in to[i]:
        if dist[j] == 100001:
            dist[j] = dist[i] + 1
            flug[j] = i
            q.append(j)
print("Yes")
for i in range(2, N + 1):
    print((flug[i]))

from collections import deque

N, M = list(map(int, input().split()))
to = [[] for i in range(N + 1)]
# dist = [100001 for i in range(N+1)]
flug = [0 for i in range(N + 1)]
to[0].append(1)
# dist[0] = 0
for i in range(M):
    a, b = list(map(int, input().split()))
    to[a].append(b)
    to[b].append(a)
q = deque([0])
while len(q) != 0:
    i = q.popleft()
    for j in to[i]:
        if flug[j] == 0:
            #            dist[j] = dist[i] +1
            flug[j] = i
            q.append(j)
print("Yes")
for i in range(2, N + 1):
    print((flug[i]))

+from collections import deque + -dist = [100001 for i in range(N + 1)] -flug = [1 for i in range(N + 1)] +# dist = [100001 for i in range(N+1)] +flug = [0 for i in range(N + 1)] -dist[0] = 0 -flug[0] = 0 +# dist[0] = 0 -q = [] -q.append(0) +q = deque([0]) -    i = q.pop(0) +    i = q.popleft() -        if dist[j] == 100001: -            dist[j] = dist[i] + 1 +        if flug[j] == 0: +            #            dist[j] = dist[i] +1