import networkx as nx

N, M = list(map(int, input().split()))

l = [list(map(int, input().split())) for _ in range(M)]

 

G = nx.Graph()

G.add_nodes_from(list(range(1, N+1)))

G.add_edges_from(l)

pre = nx.predecessor(G, 1)



print('Yes')

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

  print((pre[i][0]))
from collections import deque



N, M = map(int, input().split())

AB = [list(map(int, input().split())) for _ in range(M)]

g = [[] for _ in range(N+1)]



for a, b in AB:

  g[a].append(b)

  g[b].append(a)



d = deque([1])

l = [0]*(N+1)

while d:

  r = d.popleft()

  for s in g[r]:

    if l[s] == 0:

      d.append(s)

      l[s] = r



print("Yes", *l[2:], sep="\n")

import networkx as nx

N, M = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(M)]
G = nx.Graph()
G.add_nodes_from(list(range(1, N + 1)))
G.add_edges_from(l)
pre = nx.predecessor(G, 1)
print("Yes")
for i in range(2, N + 1):
    print((pre[i][0]))

from collections import deque

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
g = [[] for _ in range(N + 1)]
for a, b in AB:
    g[a].append(b)
    g[b].append(a)
d = deque([1])
l = [0] * (N + 1)
while d:
    r = d.popleft()
    for s in g[r]:
        if l[s] == 0:
            d.append(s)
            l[s] = r
print("Yes", *l[2:], sep="\n")

-import networkx as nx +from collections import deque -N, M = list(map(int, input().split())) -l = [list(map(int, input().split())) for _ in range(M)] -G = nx.Graph() -G.add_nodes_from(list(range(1, N + 1))) -G.add_edges_from(l) -pre = nx.predecessor(G, 1) -print("Yes") -for i in range(2, N + 1): -    print((pre[i][0])) +N, M = map(int, input().split()) +AB = [list(map(int, input().split())) for _ in range(M)] +g = [[] for _ in range(N + 1)] +for a, b in AB: +    g[a].append(b) +    g[b].append(a) +d = deque([1]) +l = [0] * (N + 1) +while d: +    r = d.popleft() +    for s in g[r]: +        if l[s] == 0: +            d.append(s) +            l[s] = r +print("Yes", *l[2:], sep="\n")