from collections import deque

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

lis = [0]*(n+1)

c = [[] for i in range(n+1)]

for i in range(m):

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

    c[a].append(b)

    c[b].append(a)

    

que = deque([1])

check = [0 for i in range(n+1)]

check[1] = 1

while que:

    now = que.popleft()

    nx = c[now]

    for i in nx:

        if check[i] == 1:

            continue

        check[i] = 1

        lis[i] = now

        que.append(i)

if 0 in lis[2:]:

    print("No")

else:

    print("Yes")

    for i in lis[2:]:

        print(i)
from collections import deque

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

lis = [0]*(n+1)

c = [[] for i in range(n+1)]

for i in range(m):

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

    c[a].append(b)

    c[b].append(a)

    

que = deque([1])

check = [0 for i in range(n+1)]

check[1] = 1

while que:

    now = que.popleft()

    nx = c[now]

    for i in nx:

        if check[i] == 1:

            continue

        check[i] = 1

        lis[i] = now

        que.append(i)

if 0 in lis[2:]:

    print("No")

else:

    print("Yes")

    print(("\n".join(map(str, lis[2:]))))

from collections import deque

n, m = list(map(int, input().split()))
lis = [0] * (n + 1)
c = [[] for i in range(n + 1)]
for i in range(m):
    a, b = list(map(int, input().split()))
    c[a].append(b)
    c[b].append(a)
que = deque([1])
check = [0 for i in range(n + 1)]
check[1] = 1
while que:
    now = que.popleft()
    nx = c[now]
    for i in nx:
        if check[i] == 1:
            continue
        check[i] = 1
        lis[i] = now
        que.append(i)
if 0 in lis[2:]:
    print("No")
else:
    print("Yes")
    for i in lis[2:]:
        print(i)

from collections import deque

n, m = list(map(int, input().split()))
lis = [0] * (n + 1)
c = [[] for i in range(n + 1)]
for i in range(m):
    a, b = list(map(int, input().split()))
    c[a].append(b)
    c[b].append(a)
que = deque([1])
check = [0 for i in range(n + 1)]
check[1] = 1
while que:
    now = que.popleft()
    nx = c[now]
    for i in nx:
        if check[i] == 1:
            continue
        check[i] = 1
        lis[i] = now
        que.append(i)
if 0 in lis[2:]:
    print("No")
else:
    print("Yes")
    print(("\n".join(map(str, lis[2:]))))

-    for i in lis[2:]: -        print(i) +    print(("\n".join(map(str, lis[2:]))))