from collections import deque

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

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

for i in range(M):

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

    Mlist[a].append(b)

    Mlist[b].append(a)



ans = [0] * (N+1)



d = deque()

d.append(1)

count = 0

while count != N:

    Q = d.popleft()

    for i in Mlist[Q]:

        if ans[i] == 0:

            ans[i] = Q

            d.append(i)

            count = count+1

print('Yes')

for i in range(N-1):

    print((ans[i+2]))

from collections import deque

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

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

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

d = deque()

for i in range(M):

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

    road[A].append(B)

    road[B].append(A)

d.append(1)

while len(d) != 0:

    look = d.popleft()

    for i in road[look]:

        if ans[i] == -1:

            d.append(i)

            ans[i] = look



print("Yes")

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

    print((ans[i]))

from collections import deque

N, M = list(map(int, input().split()))
Mlist = [[] for _ in range(N + 1)]
for i in range(M):
    a, b = list(map(int, input().split()))
    Mlist[a].append(b)
    Mlist[b].append(a)
ans = [0] * (N + 1)
d = deque()
d.append(1)
count = 0
while count != N:
    Q = d.popleft()
    for i in Mlist[Q]:
        if ans[i] == 0:
            ans[i] = Q
            d.append(i)
            count = count + 1
print("Yes")
for i in range(N - 1):
    print((ans[i + 2]))

from collections import deque

N, M = list(map(int, input().split()))
road = [[] for _ in range(N + 1)]
ans = [-1] * (N + 1)
d = deque()
for i in range(M):
    A, B = list(map(int, input().split()))
    road[A].append(B)
    road[B].append(A)
d.append(1)
while len(d) != 0:
    look = d.popleft()
    for i in road[look]:
        if ans[i] == -1:
            d.append(i)
            ans[i] = look
print("Yes")
for i in range(2, N + 1):
    print((ans[i]))

-Mlist = [[] for _ in range(N + 1)] +road = [[] for _ in range(N + 1)] +ans = [-1] * (N + 1) +d = deque() -    a, b = list(map(int, input().split())) -    Mlist[a].append(b) -    Mlist[b].append(a) -ans = [0] * (N + 1) -d = deque() +    A, B = list(map(int, input().split())) +    road[A].append(B) +    road[B].append(A) -count = 0 -while count != N: -    Q = d.popleft() -    for i in Mlist[Q]: -        if ans[i] == 0: -            ans[i] = Q +while len(d) != 0: +    look = d.popleft() +    for i in road[look]: +        if ans[i] == -1: -            count = count + 1 +            ans[i] = look -for i in range(N - 1): -    print((ans[i + 2])) +for i in range(2, N + 1): +    print((ans[i]))