

from collections import deque



room_num, path_num = list(map(int, input().split(" ")))

graph = [[] for _ in range(room_num)]

dis = [-1] * room_num

count = [0] * room_num

count[0] = 1

for _ in range(path_num):

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

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

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

dis[0] = 0

q = deque()

q.append(0)

while q:

    pop = q.popleft()

    for n in graph[pop]:

        if count[n] ==1:

            continue

        else:

            count[n] = 1

            dis[n] = pop+1

            q.append(n)

if sum(dis) == room_num:

    print("No")

else:

    del dis[0]

    print("Yes")

    for s in dis:

        print(s)
from collections import deque



room_num, path_num = list(map(int, input().split(" ")))

graph = [[] for _ in range(room_num)]

dis = [-1] * room_num

for _ in range(path_num):

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

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

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

dis[0] = 0

q = deque()

q.append(0)

while q:

    pop = q.popleft()

    for n in graph[pop]:

        if dis[n] > 0:

            pass

        else:

            dis[n] = pop+1

            q.append(n)

if -1 in dis:

    print("No")

else:

    del dis[0]

    print("Yes")

    for s in dis:

        print(s)
from collections import deque

room_num, path_num = list(map(int, input().split(" ")))
graph = [[] for _ in range(room_num)]
dis = [-1] * room_num
count = [0] * room_num
count[0] = 1
for _ in range(path_num):
    a, b = list(map(int, input().split(" ")))
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
dis[0] = 0
q = deque()
q.append(0)
while q:
    pop = q.popleft()
    for n in graph[pop]:
        if count[n] == 1:
            continue
        else:
            count[n] = 1
            dis[n] = pop + 1
            q.append(n)
if sum(dis) == room_num:
    print("No")
else:
    del dis[0]
    print("Yes")
    for s in dis:
        print(s)

from collections import deque

room_num, path_num = list(map(int, input().split(" ")))
graph = [[] for _ in range(room_num)]
dis = [-1] * room_num
for _ in range(path_num):
    a, b = list(map(int, input().split(" ")))
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
dis[0] = 0
q = deque()
q.append(0)
while q:
    pop = q.popleft()
    for n in graph[pop]:
        if dis[n] > 0:
            pass
        else:
            dis[n] = pop + 1
            q.append(n)
if -1 in dis:
    print("No")
else:
    del dis[0]
    print("Yes")
    for s in dis:
        print(s)

-count = [0] * room_num -count[0] = 1 -        if count[n] == 1: -            continue +        if dis[n] > 0: +            pass -            count[n] = 1 -if sum(dis) == room_num: +if -1 in dis: