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)