from collections import deque

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

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

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

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

for i in range(m):

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

    way[a].append(b)

    way[b].append(a)

D = deque([1])

while D:

    go = D.popleft()

    for i in way[go]:

        if reached[i] == 0:

            D.append(i)

            reached[i] = 1

            ans[i] = go

print('Yes')

for i in range(2, n + 1):

    print((ans[i]))
from collections import deque

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

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

for i in range(m):

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

    route[a].append(b)

    route[b].append(a)

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

visited[1] = 1

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

D = deque()

D.append(1)

while D:

    visit = D.popleft()

    for i in route[visit]:

        if visited[i] == 0:

            D.append(i)

            visited[i] = 1

            ans[i] = visit

print('Yes')

for i in range(2, n+1):

    print((ans[i]))
from collections import deque

n, m = list(map(int, input().split()))
way = [[] for i in range(n + 1)]
ans = [-1 for i in range(n + 1)]
reached = [0 for i in range(n + 1)]
for i in range(m):
    a, b = list(map(int, input().split()))
    way[a].append(b)
    way[b].append(a)
D = deque([1])
while D:
    go = D.popleft()
    for i in way[go]:
        if reached[i] == 0:
            D.append(i)
            reached[i] = 1
            ans[i] = go
print("Yes")
for i in range(2, n + 1):
    print((ans[i]))

from collections import deque

n, m = list(map(int, input().split()))
route = [[] for i in range(n + 1)]
for i in range(m):
    a, b = list(map(int, input().split()))
    route[a].append(b)
    route[b].append(a)
visited = [0 for i in range(n + 1)]
visited[1] = 1
ans = [0 for i in range(n + 1)]
D = deque()
D.append(1)
while D:
    visit = D.popleft()
    for i in route[visit]:
        if visited[i] == 0:
            D.append(i)
            visited[i] = 1
            ans[i] = visit
print("Yes")
for i in range(2, n + 1):
    print((ans[i]))

-way = [[] for i in range(n + 1)] -ans = [-1 for i in range(n + 1)] -reached = [0 for i in range(n + 1)] +route = [[] for i in range(n + 1)] -    way[a].append(b) -    way[b].append(a) -D = deque([1]) +    route[a].append(b) +    route[b].append(a) +visited = [0 for i in range(n + 1)] +visited[1] = 1 +ans = [0 for i in range(n + 1)] +D = deque() +D.append(1) -    go = D.popleft() -    for i in way[go]: -        if reached[i] == 0: +    visit = D.popleft() +    for i in route[visit]: +        if visited[i] == 0: -            reached[i] = 1 -            ans[i] = go +            visited[i] = 1 +            ans[i] = visit