from collections import deque



n,m=list(map(int,input().split()))



tree=[[] for i in range(n)]

for i in range(m):

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

  a-=1

  b-=1

  tree[a].append(b)

  tree[b].append(a)



dist=[-1 for i in range(n)]

dist[0]=0



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

ans[0]=0



dq=deque()

dq.append(0)

while dq:

  x=dq.popleft()

  for i in tree[x]:

    if ans[i]==-1:

      ans[i]=x

      dq.append(i)



if -1 in ans:

  print('No')

  exit()



print('Yes')

for i in ans[1:]:

  print((i+1))
from collections import deque

from sys import stdin

nii=lambda:list(map(int,stdin.readline().split()))



n,m=nii()



tree=[[] for i in range(n)]

for i in range(m):

  a,b=nii()

  a-=1

  b-=1

  tree[a].append(b)

  tree[b].append(a)



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

ans[0]=0



dq=deque()

dq.append(0)

while dq:

  x=dq.popleft()

  for i in tree[x]:

    if ans[i]==-1:

      ans[i]=x

      dq.append(i)



print('Yes')

for i in ans[1:]:

  print((i+1))
from collections import deque

n, m = list(map(int, input().split()))
tree = [[] for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)
dist = [-1 for i in range(n)]
dist[0] = 0
ans = [-1 for i in range(n)]
ans[0] = 0
dq = deque()
dq.append(0)
while dq:
    x = dq.popleft()
    for i in tree[x]:
        if ans[i] == -1:
            ans[i] = x
            dq.append(i)
if -1 in ans:
    print("No")
    exit()
print("Yes")
for i in ans[1:]:
    print((i + 1))

from collections import deque
from sys import stdin

nii = lambda: list(map(int, stdin.readline().split()))
n, m = nii()
tree = [[] for i in range(n)]
for i in range(m):
    a, b = nii()
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)
ans = [-1 for i in range(n)]
ans[0] = 0
dq = deque()
dq.append(0)
while dq:
    x = dq.popleft()
    for i in tree[x]:
        if ans[i] == -1:
            ans[i] = x
            dq.append(i)
print("Yes")
for i in ans[1:]:
    print((i + 1))

+from sys import stdin -n, m = list(map(int, input().split())) +nii = lambda: list(map(int, stdin.readline().split())) +n, m = nii() -    a, b = list(map(int, input().split())) +    a, b = nii() -dist = [-1 for i in range(n)] -dist[0] = 0 -if -1 in ans: -    print("No") -    exit()