from collections import deque



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



tree=[[0] for _ in range(N)]



for _ in range(M):

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

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

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



dist = [-1]*N

que = deque([0])

dist[0] = 0

while que:

    v = que.popleft()

    d = dist[v]

    for w in tree[v]:

        if dist[w] > -1:

            continue

        dist[w] = d + 1

        que.append(w)

ans=[0 for _ in range(N)]

for i in range(1,N):

    for t in tree[i]:

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

            ans[i]=t+1

            break



print("Yes")

for j in range(1,N):

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



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



tree=[[0] for _ in range(N)]



for _ in range(M):

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

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

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



dist = [-1]*N

que = deque([0])

dist[0] = 0

while que:

    v = que.popleft()

    d = dist[v]

    for w in tree[v]:

        if dist[w] > -1:

            continue

        dist[w] = v

        que.append(w)



print("Yes")

for j in range(1,N):

    print((dist[j]+1))
from collections import deque

N, M = list(map(int, input().split()))
tree = [[0] for _ in range(N)]
for _ in range(M):
    A, B = list(map(int, input().split()))
    tree[A - 1].append(B - 1)
    tree[B - 1].append(A - 1)
dist = [-1] * N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in tree[v]:
        if dist[w] > -1:
            continue
        dist[w] = d + 1
        que.append(w)
ans = [0 for _ in range(N)]
for i in range(1, N):
    for t in tree[i]:
        if dist[t] == dist[i] - 1:
            ans[i] = t + 1
            break
print("Yes")
for j in range(1, N):
    print((ans[j]))

from collections import deque

N, M = list(map(int, input().split()))
tree = [[0] for _ in range(N)]
for _ in range(M):
    A, B = list(map(int, input().split()))
    tree[A - 1].append(B - 1)
    tree[B - 1].append(A - 1)
dist = [-1] * N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in tree[v]:
        if dist[w] > -1:
            continue
        dist[w] = v
        que.append(w)
print("Yes")
for j in range(1, N):
    print((dist[j] + 1))

-        dist[w] = d + 1 +        dist[w] = v -ans = [0 for _ in range(N)] -for i in range(1, N): -    for t in tree[i]: -        if dist[t] == dist[i] - 1: -            ans[i] = t + 1 -            break -    print((ans[j])) +    print((dist[j] + 1))