from collections import deque

INF = 10**9 + 7

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

g = [[] for _ in range(n+1)]

for _ in range(m):

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

    g[a].append([a, b])

    g[b].append([b, a])

res = [[0, INF] for _ in range(n+1)]

res[1][1] = 0

q = deque(g[1])

while q:

    q_ = q.popleft()

    if res[q_[1]][1] == INF:

        for gi in g[q_[1]]: q.append(gi)

        res[q_[1]][0] = q_[0]

        res[q_[1]][1] = res[q_[0]][1] + 1

print("Yes")

for i in res[2:]: print((i[0]))
from collections import deque

INF = 10**9 + 7

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

g = [[] for _ in range(n+1)]

for _ in range(m):

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

    g[a].append([a, b])

    g[b].append([b, a])

res = [INF for _ in range(n+1)]

res[1] = 0

q = deque(g[1])

while q:

    q_ = q.popleft()

    if res[q_[1]] == INF:

        for gi in g[q_[1]]: q.append(gi)

        res[q_[1]] = q_[0]

print("Yes")

for i in res[2:]: print(i)
from collections import deque

INF = 10**9 + 7
n, m = list(map(int, input().split()))
g = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    g[a].append([a, b])
    g[b].append([b, a])
res = [[0, INF] for _ in range(n + 1)]
res[1][1] = 0
q = deque(g[1])
while q:
    q_ = q.popleft()
    if res[q_[1]][1] == INF:
        for gi in g[q_[1]]:
            q.append(gi)
        res[q_[1]][0] = q_[0]
        res[q_[1]][1] = res[q_[0]][1] + 1
print("Yes")
for i in res[2:]:
    print((i[0]))

from collections import deque

INF = 10**9 + 7
n, m = list(map(int, input().split()))
g = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    g[a].append([a, b])
    g[b].append([b, a])
res = [INF for _ in range(n + 1)]
res[1] = 0
q = deque(g[1])
while q:
    q_ = q.popleft()
    if res[q_[1]] == INF:
        for gi in g[q_[1]]:
            q.append(gi)
        res[q_[1]] = q_[0]
print("Yes")
for i in res[2:]:
    print(i)

-res = [[0, INF] for _ in range(n + 1)] -res[1][1] = 0 +res = [INF for _ in range(n + 1)] +res[1] = 0 -    if res[q_[1]][1] == INF: +    if res[q_[1]] == INF: -        res[q_[1]][0] = q_[0] -        res[q_[1]][1] = res[q_[0]][1] + 1 +        res[q_[1]] = q_[0] -    print((i[0])) +    print(i)