# 1からスタートしてBFS、道しるべのない部屋に到達したら、親の番号を道しるべとして設定する



import sys

readline = sys.stdin.readline



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

G = [[] for i in range(N)]

for i in range(M):

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

  G[a-1].append(b-1)

  G[b-1].append(a-1)



from collections import deque

q = deque([])

q.append([0,-1])

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

while q:

  v,parent = q.popleft()

  if ans[v] != -1:

    continue

  ans[v] = parent + 1

  for child in G[v]:

    if child == parent:

      continue

    q.append([child,v])



for i in range(1,len(ans)):

  if ans[i] == -1:

    print("No")

    exit(0)

print("Yes")

for i in range(1,len(ans)):

  print((ans[i]))
import sys

readline = sys.stdin.readline



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

G = [[] for i in range(N)]

for i in range(M):

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

  G[a - 1].append(b - 1)

  G[b - 1].append(a - 1)



ans = [None] * N

from collections import deque

q = deque([[0,-1]])

while q:

  v,parent = q.popleft()

  if ans[v] is not None:

    continue

  ans[v] = parent

  for child in G[v]:

    if ans[child] is None:

      q.append([child, v])

print("Yes")

for i in range(1,len(ans)):

  print((ans[i] + 1))
# 1からスタートしてBFS、道しるべのない部屋に到達したら、親の番号を道しるべとして設定する
import sys

readline = sys.stdin.readline
N, M = list(map(int, readline().split()))
G = [[] for i in range(N)]
for i in range(M):
    a, b = list(map(int, readline().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
from collections import deque

q = deque([])
q.append([0, -1])
ans = [-1 for i in range(N)]
while q:
    v, parent = q.popleft()
    if ans[v] != -1:
        continue
    ans[v] = parent + 1
    for child in G[v]:
        if child == parent:
            continue
        q.append([child, v])
for i in range(1, len(ans)):
    if ans[i] == -1:
        print("No")
        exit(0)
print("Yes")
for i in range(1, len(ans)):
    print((ans[i]))

import sys

readline = sys.stdin.readline
N, M = list(map(int, readline().split()))
G = [[] for i in range(N)]
for i in range(M):
    a, b = list(map(int, readline().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
ans = [None] * N
from collections import deque

q = deque([[0, -1]])
while q:
    v, parent = q.popleft()
    if ans[v] is not None:
        continue
    ans[v] = parent
    for child in G[v]:
        if ans[child] is None:
            q.append([child, v])
print("Yes")
for i in range(1, len(ans)):
    print((ans[i] + 1))

-# 1からスタートしてBFS、道しるべのない部屋に到達したら、親の番号を道しるべとして設定する +ans = [None] * N -q = deque([]) -q.append([0, -1]) -ans = [-1 for i in range(N)] +q = deque([[0, -1]]) -    if ans[v] != -1: +    if ans[v] is not None: -    ans[v] = parent + 1 +    ans[v] = parent -        if child == parent: -            continue -        q.append([child, v]) -for i in range(1, len(ans)): -    if ans[i] == -1: -        print("No") -        exit(0) +        if ans[child] is None: +            q.append([child, v]) -    print((ans[i])) +    print((ans[i] + 1))