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

tuuro = []

for i in range(m):

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

	tuuro.append((a-1,b-1))

#行ける部屋は.?

ikeru = [[] for _ in range(n)]

for i,j in tuuro:

	ikeru[i].append(j)

	ikeru[j].append(i)



fukasa = [0 for _ in range(n)]

fukasamoto = [0 for _ in range(n)]

kaisuu = 0

settansaku = set([])

listmada = [0]

setmada = set([0])



while len(setmada) != 0:

	kaisuu += 1

	for i in listmada[:]:

		settansaku.add(i)

		listmada.remove(i)

		setmada.remove(i)

		for k in ikeru[i]:

			if not k in setmada:

				if not k in settansaku:

					listmada.append(k)

					setmada.add(k)

					fukasa[k] = kaisuu

					fukasamoto[k] = i+1



print("Yes")

for i in range(1, n):

	print((fukasamoto[i]))
n, m = list(map(int, input().split()))

ikeru = [[] for _ in range(n)]

for i in range(m):

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

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

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



fukasa = [0 for _ in range(n)]

fukasamoto = [0 for _ in range(n)]

kaisuu = 0

settansaku = set([])

setmada = {0}

kouho = 1



while kouho != 0:

	kaisuu += 1

	for i in list(setmada):

		settansaku.add(i)

		setmada.remove(i)

		kouho -= 1

		for k in ikeru[i]:

			if not k in setmada:

				if not k in settansaku:

					setmada.add(k)

					kouho += 1

					fukasa[k] = kaisuu

					fukasamoto[k] = i+1



print("Yes")

for i in range(1, n):

	print((fukasamoto[i]))
n, m = list(map(int, input().split()))
tuuro = []
for i in range(m):
    a, b = list(map(int, input().split()))
    tuuro.append((a - 1, b - 1))
# 行ける部屋は.?
ikeru = [[] for _ in range(n)]
for i, j in tuuro:
    ikeru[i].append(j)
    ikeru[j].append(i)
fukasa = [0 for _ in range(n)]
fukasamoto = [0 for _ in range(n)]
kaisuu = 0
settansaku = set([])
listmada = [0]
setmada = set([0])
while len(setmada) != 0:
    kaisuu += 1
    for i in listmada[:]:
        settansaku.add(i)
        listmada.remove(i)
        setmada.remove(i)
        for k in ikeru[i]:
            if not k in setmada:
                if not k in settansaku:
                    listmada.append(k)
                    setmada.add(k)
                    fukasa[k] = kaisuu
                    fukasamoto[k] = i + 1
print("Yes")
for i in range(1, n):
    print((fukasamoto[i]))

n, m = list(map(int, input().split()))
ikeru = [[] for _ in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    ikeru[a - 1].append(b - 1)
    ikeru[b - 1].append(a - 1)
fukasa = [0 for _ in range(n)]
fukasamoto = [0 for _ in range(n)]
kaisuu = 0
settansaku = set([])
setmada = {0}
kouho = 1
while kouho != 0:
    kaisuu += 1
    for i in list(setmada):
        settansaku.add(i)
        setmada.remove(i)
        kouho -= 1
        for k in ikeru[i]:
            if not k in setmada:
                if not k in settansaku:
                    setmada.add(k)
                    kouho += 1
                    fukasa[k] = kaisuu
                    fukasamoto[k] = i + 1
print("Yes")
for i in range(1, n):
    print((fukasamoto[i]))

-tuuro = [] +ikeru = [[] for _ in range(n)] -    tuuro.append((a - 1, b - 1)) -# 行ける部屋は.? -ikeru = [[] for _ in range(n)] -for i, j in tuuro: -    ikeru[i].append(j) -    ikeru[j].append(i) +    ikeru[a - 1].append(b - 1) +    ikeru[b - 1].append(a - 1) -listmada = [0] -setmada = set([0]) -while len(setmada) != 0: +setmada = {0} +kouho = 1 +while kouho != 0: -    for i in listmada[:]: +    for i in list(setmada): -        listmada.remove(i) +        kouho -= 1 -                    listmada.append(k) +                    kouho += 1