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

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

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

from collections import deque



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]=1



que=deque()

que.append(0)



while que:

  x=que.popleft()

  for i in tree[x]:

    if ans[i]==-1:

      ans[i]=x

      que.append(i)



if -1 in ans:

  print('No')

else:

  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

nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
from collections import deque

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] = 1
que = deque()
que.append(0)
while que:
    x = que.popleft()
    for i in tree[x]:
        if ans[i] == -1:
            ans[i] = x
            que.append(i)
if -1 in ans:
    print("No")
else:
    print("Yes")
    for i in ans[1:]:
        print((i + 1))

-from collections import deque +lnii = lambda: list(map(int, stdin.readline().split())) +from collections import deque + -ans[0] = 0 -dq = deque() -dq.append(0) -while dq: -    x = dq.popleft() +ans[0] = 1 +que = deque() +que.append(0) +while que: +    x = que.popleft() -            dq.append(i) -print("Yes") -for i in ans[1:]: -    print((i + 1)) +            que.append(i) +if -1 in ans: +    print("No") +else: +    print("Yes") +    for i in ans[1:]: +        print((i + 1))