from collections import deque

import sys



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

graph = [[] for _ in range(N + 1)]

for i in range(M):

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

    graph[a].append(b)

    graph[b].append(a)



que = deque([1])

ans = [0]*(N+1)



while que:

    x = deque.popleft(que)

    for i in graph[x]:

        if ans[i] != 0:

            continue

        ans[i] = x

        que.append(i)

        

for i in range(2,N+1):

    if ans[i] == 0:

        print('No')

        sys.exit()

        

print('Yes')

for i in range(2,N+1):

    print((ans[i]))
N,M = list(map(int,input().split()))

AB = [list(map(int,input().split())) for i in range(M)]

 

ans = [-1] * (N+1)

graph = [[] for _ in range(N+1)]

for a,b in AB:

    graph[a].append(b)

    graph[b].append(a)

    



from collections import deque

import sys

ans = [-1] * (N+1)

todo = deque([(1,0)])

while todo:

    x,parent = deque.popleft(todo)

    #ans[x] = parent

    for y in graph[x]:

        # if y == parent:

        #     continue

        if ans[y] != -1:

            continue

        ans[y] = x

        todo.append((y,x))

        



for i in range(2,N+1):

    if ans[i] == -1:

        print('No')

        sys.exit()

        

print('Yes')

for i in range(2,N+1):

    print((ans[i]))
from collections import deque
import sys

N, M = list(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for i in range(M):
    a, b = list(map(int, input().split()))
    graph[a].append(b)
    graph[b].append(a)
que = deque([1])
ans = [0] * (N + 1)
while que:
    x = deque.popleft(que)
    for i in graph[x]:
        if ans[i] != 0:
            continue
        ans[i] = x
        que.append(i)
for i in range(2, N + 1):
    if ans[i] == 0:
        print("No")
        sys.exit()
print("Yes")
for i in range(2, N + 1):
    print((ans[i]))

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
ans = [-1] * (N + 1)
graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
from collections import deque
import sys

ans = [-1] * (N + 1)
todo = deque([(1, 0)])
while todo:
    x, parent = deque.popleft(todo)
    # ans[x] = parent
    for y in graph[x]:
        # if y == parent:
        #     continue
        if ans[y] != -1:
            continue
        ans[y] = x
        todo.append((y, x))
for i in range(2, N + 1):
    if ans[i] == -1:
        print("No")
        sys.exit()
print("Yes")
for i in range(2, N + 1):
    print((ans[i]))

+N, M = list(map(int, input().split())) +AB = [list(map(int, input().split())) for i in range(M)] +ans = [-1] * (N + 1) +graph = [[] for _ in range(N + 1)] +for a, b in AB: +    graph[a].append(b) +    graph[b].append(a) -N, M = list(map(int, input().split())) -graph = [[] for _ in range(N + 1)] -for i in range(M): -    a, b = list(map(int, input().split())) -    graph[a].append(b) -    graph[b].append(a) -que = deque([1]) -ans = [0] * (N + 1) -while que: -    x = deque.popleft(que) -    for i in graph[x]: -        if ans[i] != 0: +ans = [-1] * (N + 1) +todo = deque([(1, 0)]) +while todo: +    x, parent = deque.popleft(todo) +    # ans[x] = parent +    for y in graph[x]: +        # if y == parent: +        #     continue +        if ans[y] != -1: -        ans[i] = x -        que.append(i) +        ans[y] = x +        todo.append((y, x)) -    if ans[i] == 0: +    if ans[i] == -1: