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



edges = [[] for _ in range(n)]



for _ in range(m):

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

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

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



q = [0]



ans = [-1]*n

ans[0] = 0

count = 1



while q:

    l = q.pop(0)

    for i in edges[l]:

        if ans[i] == -1:

            ans[i] = l

            count += 1

            q.append(i)

    if count == n:

        break



if count == n:

    print('Yes')

    for i in ans[1:]:

        print((i+1))

else:

    print('No')

import sys

input = sys.stdin.readline



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



edges = [[] for _ in range(n)]



for _ in range(m):

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

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

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



q = [0]



ans = [-1]*n

ans[0] = 0

count = 1



while q:

    l = q.pop(0)

    for i in edges[l]:

        if ans[i] == -1:

            ans[i] = l

            count += 1

            q.append(i)

    if count == n:

        break



if count == n:

    print('Yes')

    for i in ans[1:]:

        print((i+1))

else:

    print('No')

n, m = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
q = [0]
ans = [-1] * n
ans[0] = 0
count = 1
while q:
    l = q.pop(0)
    for i in edges[l]:
        if ans[i] == -1:
            ans[i] = l
            count += 1
            q.append(i)
    if count == n:
        break
if count == n:
    print("Yes")
    for i in ans[1:]:
        print((i + 1))
else:
    print("No")

import sys

input = sys.stdin.readline
n, m = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
q = [0]
ans = [-1] * n
ans[0] = 0
count = 1
while q:
    l = q.pop(0)
    for i in edges[l]:
        if ans[i] == -1:
            ans[i] = l
            count += 1
            q.append(i)
    if count == n:
        break
if count == n:
    print("Yes")
    for i in ans[1:]:
        print((i + 1))
else:
    print("No")

+import sys + +input = sys.stdin.readline