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



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

for i in range(m):

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

    root[a-1].append(b)

    root[b-1].append(a)



kakutei = [1]



answer_li = [0]*n



while kakutei:

    k = kakutei.pop(0)

    for r in root[k-1]:

        if answer_li[r-1] == 0:

            kakutei.append(r)

            answer_li[r-1] = k



answer_li = answer_li[1:]

if 0 in answer_li:

    print('No')

else:

    print('Yes')

    for i in answer_li:

        print(i)

import sys

input = sys.stdin.readline



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



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

for i in range(m):

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

    root[a-1].append(b)

    root[b-1].append(a)



kakutei = [1]



answer_li = [0]*n



while kakutei:

    k = kakutei.pop(0)

    for r in root[k-1]:

        if answer_li[r-1] == 0:

            kakutei.append(r)

            answer_li[r-1] = k



answer_li = answer_li[1:]

if 0 in answer_li:

    print('No')

else:

    print('Yes')

    for i in answer_li:

        print(i)

n, m = list(map(int, input().split()))
root = [[] for _ in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    root[a - 1].append(b)
    root[b - 1].append(a)
kakutei = [1]
answer_li = [0] * n
while kakutei:
    k = kakutei.pop(0)
    for r in root[k - 1]:
        if answer_li[r - 1] == 0:
            kakutei.append(r)
            answer_li[r - 1] = k
answer_li = answer_li[1:]
if 0 in answer_li:
    print("No")
else:
    print("Yes")
    for i in answer_li:
        print(i)

import sys

input = sys.stdin.readline
n, m = list(map(int, input().split()))
root = [[] for _ in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    root[a - 1].append(b)
    root[b - 1].append(a)
kakutei = [1]
answer_li = [0] * n
while kakutei:
    k = kakutei.pop(0)
    for r in root[k - 1]:
        if answer_li[r - 1] == 0:
            kakutei.append(r)
            answer_li[r - 1] = k
answer_li = answer_li[1:]
if 0 in answer_li:
    print("No")
else:
    print("Yes")
    for i in answer_li:
        print(i)

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