from collections import deque



N, M = [int(s) for s in input().split()]

edge = [[int(s) - 1 for s in input().split()] for _ in range(M)]

graph = [[] for _ in range(N)]

for i, j in edge:

    graph[i].append(j)

    graph[j].append(i)



dq = deque([0])

visited = [False] * N

visited[0] = True

parent = [0]*N

while(dq):

    search_obj = dq.pop()

    for candidate_obj in graph[search_obj]:

        if not visited[candidate_obj]:

            dq.appendleft(candidate_obj)

            parent[candidate_obj] = search_obj

            visited[candidate_obj] = True



total_visited = sum(visited)

if total_visited < N:

    print('No')

else:

    print('Yes')

    for i in range(1, N):

        print((parent[i]+1))
from collections import deque



N, M = [int(s) for s in input().split()]

edge = [[int(s) - 1 for s in input().split()] for _ in range(M)]

graph = [[] for _ in range(N)]

for i, j in edge:

    graph[i].append(j)

    graph[j].append(i)



dq = deque([0])

parent = [0] * N

parent[0] = 1

while(dq):

    search_obj = dq.pop()

    for candidate_obj in graph[search_obj]:

        if not parent[candidate_obj]:

            dq.appendleft(candidate_obj)

            parent[candidate_obj] = search_obj + 1



total_visited = sum([x != 0 for x in parent])

if total_visited < N:

    print('No')

else:

    print('Yes')

    for i in range(1, N):

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

N, M = [int(s) for s in input().split()]
edge = [[int(s) - 1 for s in input().split()] for _ in range(M)]
graph = [[] for _ in range(N)]
for i, j in edge:
    graph[i].append(j)
    graph[j].append(i)
dq = deque([0])
visited = [False] * N
visited[0] = True
parent = [0] * N
while dq:
    search_obj = dq.pop()
    for candidate_obj in graph[search_obj]:
        if not visited[candidate_obj]:
            dq.appendleft(candidate_obj)
            parent[candidate_obj] = search_obj
            visited[candidate_obj] = True
total_visited = sum(visited)
if total_visited < N:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print((parent[i] + 1))

from collections import deque

N, M = [int(s) for s in input().split()]
edge = [[int(s) - 1 for s in input().split()] for _ in range(M)]
graph = [[] for _ in range(N)]
for i, j in edge:
    graph[i].append(j)
    graph[j].append(i)
dq = deque([0])
parent = [0] * N
parent[0] = 1
while dq:
    search_obj = dq.pop()
    for candidate_obj in graph[search_obj]:
        if not parent[candidate_obj]:
            dq.appendleft(candidate_obj)
            parent[candidate_obj] = search_obj + 1
total_visited = sum([x != 0 for x in parent])
if total_visited < N:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print((parent[i]))

-visited = [False] * N -visited[0] = True +parent[0] = 1 -        if not visited[candidate_obj]: +        if not parent[candidate_obj]: -            parent[candidate_obj] = search_obj -            visited[candidate_obj] = True -total_visited = sum(visited) +            parent[candidate_obj] = search_obj + 1 +total_visited = sum([x != 0 for x in parent]) -        print((parent[i] + 1)) +        print((parent[i]))