from collections import deque





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

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



for i in range(M):

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

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

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



route = deque([0])

dist = [False]*N

prev = [-1]*N

dist[0] = 0



while route:

    v = route.popleft()

    for u in to[v]:

        if dist[u]: continue

        dist[u] = dist[v]+1

        prev[u] = v

        route.append(u)



print("Yes")

for pre in prev[1:]:

    print((pre+1))
from collections import deque





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

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



for i in range(M):

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

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

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



route = deque([0])

dist = [0]*N

prev = [-1]*N

dist[0] = 0



while route:

    v = route.popleft()

    for u in to[v]:

        if dist[u]: continue

        dist[u] = dist[v]+1

        prev[u] = v

        route.append(u)



print("Yes")

for pre in prev[1:]:

    print((pre+1))
from collections import deque

N, M = list(map(int, input().split()))
to = [[] for _ in range(N)]
for i in range(M):
    A, B = list(map(int, input().split()))
    to[A - 1].append(B - 1)
    to[B - 1].append(A - 1)
route = deque([0])
dist = [False] * N
prev = [-1] * N
dist[0] = 0
while route:
    v = route.popleft()
    for u in to[v]:
        if dist[u]:
            continue
        dist[u] = dist[v] + 1
        prev[u] = v
        route.append(u)
print("Yes")
for pre in prev[1:]:
    print((pre + 1))

from collections import deque

N, M = list(map(int, input().split()))
to = [[] for _ in range(N)]
for i in range(M):
    A, B = list(map(int, input().split()))
    to[A - 1].append(B - 1)
    to[B - 1].append(A - 1)
route = deque([0])
dist = [0] * N
prev = [-1] * N
dist[0] = 0
while route:
    v = route.popleft()
    for u in to[v]:
        if dist[u]:
            continue
        dist[u] = dist[v] + 1
        prev[u] = v
        route.append(u)
print("Yes")
for pre in prev[1:]:
    print((pre + 1))

-dist = [False] * N +dist = [0] * N