import queue



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

puted = [1]*(n+1)



ab = [[] for i in range(n+1)]

for i in range(m):

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

	ab[a].append(b)

	ab[b].append(a)



q = queue.Queue()

flg = [-1]*n

flg[0] = 0

q.put(1)



while not q.empty():

	item = q.get()

	for i in ab[item]:

		if puted[i]:

			flg[i-1]=item

			q.put(i)

			puted[i]=0



if -1 in flg:

	print("No")

	exit()



print("Yes")

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

	print((flg[i]))

from collections import deque



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

puted = [1]*(n+1)



ab = [[] for i in range(n+1)]

for i in range(m):

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

	ab[a].append(b)

	ab[b].append(a)



q = deque([1])

flg = [-1]*n

flg[0] = 0



while q:

	item = q.popleft()

	for i in ab[item]:

		if puted[i]:

			flg[i-1]=item

			q.append(i)

			puted[i]=0



if -1 in flg:

	print("No")

	exit()



print("Yes")

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

	print((flg[i]))

import queue

n, m = list(map(int, input().split()))
puted = [1] * (n + 1)
ab = [[] for i in range(n + 1)]
for i in range(m):
    a, b = list(map(int, input().split()))
    ab[a].append(b)
    ab[b].append(a)
q = queue.Queue()
flg = [-1] * n
flg[0] = 0
q.put(1)
while not q.empty():
    item = q.get()
    for i in ab[item]:
        if puted[i]:
            flg[i - 1] = item
            q.put(i)
            puted[i] = 0
if -1 in flg:
    print("No")
    exit()
print("Yes")
for i in range(1, len(flg)):
    print((flg[i]))

from collections import deque

n, m = list(map(int, input().split()))
puted = [1] * (n + 1)
ab = [[] for i in range(n + 1)]
for i in range(m):
    a, b = list(map(int, input().split()))
    ab[a].append(b)
    ab[b].append(a)
q = deque([1])
flg = [-1] * n
flg[0] = 0
while q:
    item = q.popleft()
    for i in ab[item]:
        if puted[i]:
            flg[i - 1] = item
            q.append(i)
            puted[i] = 0
if -1 in flg:
    print("No")
    exit()
print("Yes")
for i in range(1, len(flg)):
    print((flg[i]))

-import queue +from collections import deque -q = queue.Queue() +q = deque([1]) -q.put(1) -while not q.empty(): -    item = q.get() +while q: +    item = q.popleft() -            q.put(i) +            q.append(i)