from collections import deque



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

arr = [[] for n in range(N)]

que = deque([1])



for m in range(M):

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

    arr[a - 1].append(b)

    arr[b - 1].append(a)



dist = [-1] * N

dist[0] = 0

arr2 = [0] * (N - 1)



print("Yes")

while que:

    c = que.popleft()

    for i in arr[c - 1]:

        if dist[i - 1] != -1:

            continue



        dist[i - 1] = 0

        arr2[i - 2] = c

        que.append(i)



for i in arr2:

    print(i)





from collections import deque



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

arr = [[] for n in range(N)]

for m in range(M):

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

    arr[a - 1].append(b - 1)

    arr[b - 1].append(a - 1)



que = deque([0])

dist = [-1] * N

dist[0] = 0

pre = [0] * N



while que:

    c = que.popleft()

    for i in arr[c]:

        if dist[i] != -1:

            continue

        dist[i] = 0

        pre[i] = c

        que.append(i)



print("Yes")  # 必ずYesになる

for i in pre[1:]:

    print((i+1))

from collections import deque

N, M = list(map(int, input().split()))
arr = [[] for n in range(N)]
que = deque([1])
for m in range(M):
    a, b = list(map(int, input().split()))
    arr[a - 1].append(b)
    arr[b - 1].append(a)
dist = [-1] * N
dist[0] = 0
arr2 = [0] * (N - 1)
print("Yes")
while que:
    c = que.popleft()
    for i in arr[c - 1]:
        if dist[i - 1] != -1:
            continue
        dist[i - 1] = 0
        arr2[i - 2] = c
        que.append(i)
for i in arr2:
    print(i)

from collections import deque

N, M = list(map(int, input().split()))
arr = [[] for n in range(N)]
for m in range(M):
    a, b = list(map(int, input().split()))
    arr[a - 1].append(b - 1)
    arr[b - 1].append(a - 1)
que = deque([0])
dist = [-1] * N
dist[0] = 0
pre = [0] * N
while que:
    c = que.popleft()
    for i in arr[c]:
        if dist[i] != -1:
            continue
        dist[i] = 0
        pre[i] = c
        que.append(i)
print("Yes")  # 必ずYesになる
for i in pre[1:]:
    print((i + 1))

-que = deque([1]) -    arr[a - 1].append(b) -    arr[b - 1].append(a) +    arr[a - 1].append(b - 1) +    arr[b - 1].append(a - 1) +que = deque([0]) -arr2 = [0] * (N - 1) -print("Yes") +pre = [0] * N -    for i in arr[c - 1]: -        if dist[i - 1] != -1: +    for i in arr[c]: +        if dist[i] != -1: -        dist[i - 1] = 0 -        arr2[i - 2] = c +        dist[i] = 0 +        pre[i] = c -for i in arr2: -    print(i) +print("Yes")  # 必ずYesになる +for i in pre[1:]: +    print((i + 1))