from collections import deque

n, m = list(map(int, input().split()))

M = [[] for i in range(n)]

for i in range(m):

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

    a, b = a - 1, b - 1

    M[a].append(b)

    M[b].append(a)

#print(M)



R = [-1 for i in range(n)]

Q = deque([(0, -2)])

while len(Q) > 0:

    t = Q[0][0]

    b = Q[0][1]

    #print(t)

    #print(b)

    Q.popleft()

    if R[t] == -1:

        R[t] = b

        for i in range(len(M[t])):

            if R[M[t][i]] == -1:

                Q.append((M[t][i], t))

            else:

                pass

    else:

        pass

#print(R)



f = 0

for i in range(n):

    if R[i] == -1:

        f = 1

        break  

    else:

        pass



if f == 1:

    print('No')

else:

    print('Yes')

    for i in range(1, n):

        print((R[i] + 1))
from collections import deque

n, m = list(map(int, input().split()))

TO = [[] for i in range(n)] #隣接リスト adjacency list

for i in range(m):

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

    a, b = a - 1, b -1

    TO[a].append(b)

    TO[b].append(a)



#BFS

#変数定義

Q = deque([])

DIST = [-1 for i in range(n)]

PRE = [-1 for i in range(n)]

#初期値の設定

DIST[0] = 0

Q.append(0)

#処理

while len(Q) > 0:

    x = Q.popleft()  

    for i in range(len(TO[x])):

        y = TO[x][i]

        if DIST[y] != -1: continue

        DIST[y] = DIST[x] + 1

        PRE[y] = x

        Q.append(y)



print('Yes')

for i in range(n):

    if i == 0: continue

    ans = PRE[i] + 1 

    print(ans)
from collections import deque

n, m = list(map(int, input().split()))
M = [[] for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    M[a].append(b)
    M[b].append(a)
# print(M)
R = [-1 for i in range(n)]
Q = deque([(0, -2)])
while len(Q) > 0:
    t = Q[0][0]
    b = Q[0][1]
    # print(t)
    # print(b)
    Q.popleft()
    if R[t] == -1:
        R[t] = b
        for i in range(len(M[t])):
            if R[M[t][i]] == -1:
                Q.append((M[t][i], t))
            else:
                pass
    else:
        pass
# print(R)
f = 0
for i in range(n):
    if R[i] == -1:
        f = 1
        break
    else:
        pass
if f == 1:
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print((R[i] + 1))

from collections import deque

n, m = list(map(int, input().split()))
TO = [[] for i in range(n)]  # 隣接リスト adjacency list
for i in range(m):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    TO[a].append(b)
    TO[b].append(a)
# BFS
# 変数定義
Q = deque([])
DIST = [-1 for i in range(n)]
PRE = [-1 for i in range(n)]
# 初期値の設定
DIST[0] = 0
Q.append(0)
# 処理
while len(Q) > 0:
    x = Q.popleft()
    for i in range(len(TO[x])):
        y = TO[x][i]
        if DIST[y] != -1:
            continue
        DIST[y] = DIST[x] + 1
        PRE[y] = x
        Q.append(y)
print("Yes")
for i in range(n):
    if i == 0:
        continue
    ans = PRE[i] + 1
    print(ans)

-M = [[] for i in range(n)] +TO = [[] for i in range(n)]  # 隣接リスト adjacency list -    M[a].append(b) -    M[b].append(a) -# print(M) -R = [-1 for i in range(n)] -Q = deque([(0, -2)]) +    TO[a].append(b) +    TO[b].append(a) +# BFS +# 変数定義 +Q = deque([]) +DIST = [-1 for i in range(n)] +PRE = [-1 for i in range(n)] +# 初期値の設定 +DIST[0] = 0 +Q.append(0) +# 処理 -    t = Q[0][0] -    b = Q[0][1] -    # print(t) -    # print(b) -    Q.popleft() -    if R[t] == -1: -        R[t] = b -        for i in range(len(M[t])): -            if R[M[t][i]] == -1: -                Q.append((M[t][i], t)) -            else: -                pass -    else: -        pass -# print(R) -f = 0 +    x = Q.popleft() +    for i in range(len(TO[x])): +        y = TO[x][i] +        if DIST[y] != -1: +            continue +        DIST[y] = DIST[x] + 1 +        PRE[y] = x +        Q.append(y) +print("Yes") -    if R[i] == -1: -        f = 1 -        break -    else: -        pass -if f == 1: -    print("No") -else: -    print("Yes") -    for i in range(1, n): -        print((R[i] + 1)) +    if i == 0: +        continue +    ans = PRE[i] + 1 +    print(ans)