import queue

import sys

imput = sys.stdin.readline



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



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

dist = [99999]*(n)

par = [0] * (n)



for i in range(m):

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

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

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

    

q=queue.Queue()

dist[0] = 0

q.put((0,0))



while not q.empty():

    

    x,d = q.get()

    

    for i in conne[x]:

        if dist[i]==99999:

            q.put((i,d+1))

            par[i] = x

            dist[i] = d+1



print("Yes")    



for i in par[1:]:

    print((i+1))



import queue

import sys

imput = sys.stdin.readline



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



conne = [[] for _ in range(n+1)]

dist = [99999]*(n+1)

par = [0] * (n+1)



for i in range(m):

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

    conne[a].append(b)

    conne[b].append(a)

    

q=queue.Queue()

dist[1] = 0

q.put((1,0))



while not q.empty():

    

    x,d = q.get()

    

    for i in conne[x]:

        if dist[i]==99999:

            q.put((i,d+1))

            par[i] = x

            dist[i] = d+1





print("Yes")    



for i in par[2:]:

    print(i)



import queue
import sys

imput = sys.stdin.readline
n, m = list(map(int, input().split()))
conne = [[] for _ in range(n)]
dist = [99999] * (n)
par = [0] * (n)
for i in range(m):
    a, b = list(map(int, input().split()))
    conne[a - 1].append(b - 1)
    conne[b - 1].append(a - 1)
q = queue.Queue()
dist[0] = 0
q.put((0, 0))
while not q.empty():
    x, d = q.get()
    for i in conne[x]:
        if dist[i] == 99999:
            q.put((i, d + 1))
            par[i] = x
            dist[i] = d + 1
print("Yes")
for i in par[1:]:
    print((i + 1))

import queue
import sys

imput = sys.stdin.readline
n, m = list(map(int, input().split()))
conne = [[] for _ in range(n + 1)]
dist = [99999] * (n + 1)
par = [0] * (n + 1)
for i in range(m):
    a, b = list(map(int, input().split()))
    conne[a].append(b)
    conne[b].append(a)
q = queue.Queue()
dist[1] = 0
q.put((1, 0))
while not q.empty():
    x, d = q.get()
    for i in conne[x]:
        if dist[i] == 99999:
            q.put((i, d + 1))
            par[i] = x
            dist[i] = d + 1
print("Yes")
for i in par[2:]:
    print(i)

-conne = [[] for _ in range(n)] -dist = [99999] * (n) -par = [0] * (n) +conne = [[] for _ in range(n + 1)] +dist = [99999] * (n + 1) +par = [0] * (n + 1) -    conne[a - 1].append(b - 1) -    conne[b - 1].append(a - 1) +    conne[a].append(b) +    conne[b].append(a) -dist[0] = 0 -q.put((0, 0)) +dist[1] = 0 +q.put((1, 0)) -for i in par[1:]: -    print((i + 1)) +for i in par[2:]: +    print(i)