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)

    



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))

        



if -1 in ans[2:]:

    print('No')

else:

    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)
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))
if -1 in ans[2:]:
    print("No")
else:
    print("Yes")
    for i in range(2, N + 1):
        print((ans[i]))

-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])) +if -1 in ans[2:]: +    print("No") +else: +    print("Yes") +    for i in range(2, N + 1): +        print((ans[i]))