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=deque([None]*N)

r[0]=0

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.popleft()

for i in range(N-1):

  print((r.popleft()))
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

r[0]=0

while q:

  x=q.popleft()

  for i in to[x]:

    if r[i] is None:

      q.append(i)

      r[i]=x+1

      

print('Yes')

for i in range(N):

  if r[i]!=0:

    print((r[i]))
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 = deque([None] * N)
r[0] = 0
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.popleft()
for i in range(N - 1):
    print((r.popleft()))

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
r[0] = 0
while q:
    x = q.popleft()
    for i in to[x]:
        if r[i] is None:
            q.append(i)
            r[i] = x + 1
print("Yes")
for i in range(N):
    if r[i] != 0:
        print((r[i]))

-r = deque([None] * N) +r = [None] * N -r.popleft() -for i in range(N - 1): -    print((r.popleft())) +for i in range(N): +    if r[i] != 0: +        print((r[i]))