import networkx as nx
N, M = map(int, input().split())

edge_list = s = [input().split() for i in range(M)]
G = nx.Graph()
G.add_edges_from(edge_list)

if [] in nx.shortest_path(G, target=str(1)).values():
  print("No")
else:
  print("Yes")
  for i in range(len(list(nx.shortest_path(G, target=str(1)).values()))-1):
    print(nx.shortest_path(G, target=str(1))[str(i+2)][1])
      