from collections import deque



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

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

for _ in range(m):

    a, b = [int(x)-1 for x in input().split()]

    edges[a].append(b)

    edges[b].append(a)



next_v = deque([0])

history = [-1]*n

INF = 10**18

dist = [INF]*n

dist[0] = 0

while next_v:

    v = next_v.popleft()



    for v2 in edges[v]:

        if dist[v2] <= dist[v]+1:

            continue

        dist[v2] = dist[v]+1

        history[v2] = v

        next_v.append(v2)





print('Yes')

for x in history[1:]:

    print((x+1))

from collections import deque

import sys

input = sys.stdin.readline

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

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

for _ in range(m):

    a, b = [int(x)-1 for x in input().split()]

    edges[a].append(b)

    edges[b].append(a)



next_v = deque([0])

prev = [-1]*n

while next_v:

    v = next_v.popleft()

    for v2 in edges[v]:

        if prev[v2] != -1:

            continue

        prev[v2] = v+1

        next_v.append(v2)

print('Yes')

for x in prev[1:]:

    print(x)

from collections import deque

n, m = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = [int(x) - 1 for x in input().split()]
    edges[a].append(b)
    edges[b].append(a)
next_v = deque([0])
history = [-1] * n
INF = 10**18
dist = [INF] * n
dist[0] = 0
while next_v:
    v = next_v.popleft()
    for v2 in edges[v]:
        if dist[v2] <= dist[v] + 1:
            continue
        dist[v2] = dist[v] + 1
        history[v2] = v
        next_v.append(v2)
print("Yes")
for x in history[1:]:
    print((x + 1))

from collections import deque
import sys

input = sys.stdin.readline
n, m = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = [int(x) - 1 for x in input().split()]
    edges[a].append(b)
    edges[b].append(a)
next_v = deque([0])
prev = [-1] * n
while next_v:
    v = next_v.popleft()
    for v2 in edges[v]:
        if prev[v2] != -1:
            continue
        prev[v2] = v + 1
        next_v.append(v2)
print("Yes")
for x in prev[1:]:
    print(x)

+import sys +input = sys.stdin.readline -history = [-1] * n -INF = 10**18 -dist = [INF] * n -dist[0] = 0 +prev = [-1] * n -        if dist[v2] <= dist[v] + 1: +        if prev[v2] != -1: -        dist[v2] = dist[v] + 1 -        history[v2] = v +        prev[v2] = v + 1 -for x in history[1:]: -    print((x + 1)) +for x in prev[1:]: +    print(x)