from collections import deque

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

to=[[] for _ in range(N)]

for _ in range(M):

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

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

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

q=deque([0])

r=[None]*N

while q:

  x=q.popleft()

  for i in to[x]:

    if r[i] is None:

      q.append(i)

      r[i]=x+1

print('Yes')

print(('\n'.join(map(str,r[1:]))))
from collections import deque

N,M,*AB=map(int,open(0).read().split())

to=[[] for _ in range(N)]

for a,b in zip(*[iter(AB)]*2):

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

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

q=deque([0])

r=[None]*N

while q:

  x=q.popleft()

  for i in to[x]:

    if r[i] is None:

      q.append(i)

      r[i]=x+1

print("Yes",*r[1:],sep="\n")

from collections import deque

N, M = list(map(int, input().split()))
to = [[] for _ in range(N)]
for _ in range(M):
    a, b = list(map(int, input().split()))
    to[a - 1].append(b - 1)
    to[b - 1].append(a - 1)
q = deque([0])
r = [None] * N
while q:
    x = q.popleft()
    for i in to[x]:
        if r[i] is None:
            q.append(i)
            r[i] = x + 1
print("Yes")
print(("\n".join(map(str, r[1:]))))

from collections import deque

N, M, *AB = map(int, open(0).read().split())
to = [[] for _ in range(N)]
for a, b in zip(*[iter(AB)] * 2):
    to[a - 1].append(b - 1)
    to[b - 1].append(a - 1)
q = deque([0])
r = [None] * N
while q:
    x = q.popleft()
    for i in to[x]:
        if r[i] is None:
            q.append(i)
            r[i] = x + 1
print("Yes", *r[1:], sep="\n")

-N, M = list(map(int, input().split())) +N, M, *AB = map(int, open(0).read().split()) -for _ in range(M): -    a, b = list(map(int, input().split())) +for a, b in zip(*[iter(AB)] * 2): -print("Yes") -print(("\n".join(map(str, r[1:])))) +print("Yes", *r[1:], sep="\n")