from collections import deque



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

root_dict = {}



for _ in range(m):

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

    if a not in root_dict:

        root_dict[a] = deque([b])

    else:

        root_dict[a].append(b)

    if b not in root_dict:

        root_dict[b] = deque([a])

    else:

        root_dict[b].append(a)



visited = [1] + [-1] * (n-1)



done = deque([1])



while done:

    x = done.popleft()

    while root_dict[x]:

        i = root_dict[x].popleft()

        if visited[i-1] < 0:

            visited[i-1] = x

            done.append(i)



if -1 in visited:

    print("No")

else:

    print("Yes")

    for i in range(1, n):

        print((visited[i]))

from collections import deque



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

root_dict = {}



for _ in range(m):

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

    if a not in root_dict:

        root_dict[a] = [b]

    else:

        root_dict[a].append(b)

    if b not in root_dict:

        root_dict[b] = [a]

    else:

        root_dict[b].append(a)



visited = [1] + [-1] * (n-1)



done = deque([1])



while done:

    x = done.popleft()

    for i in root_dict[x]:

        if visited[i-1] < 0:

            visited[i-1] = x

            done.append(i)



if -1 in visited:

    print("No")

else:

    print("Yes")

    for i in range(1, n):

        print((visited[i]))
from collections import deque

n, m = list(map(int, input().split()))
root_dict = {}
for _ in range(m):
    a, b = list(map(int, input().split()))
    if a not in root_dict:
        root_dict[a] = deque([b])
    else:
        root_dict[a].append(b)
    if b not in root_dict:
        root_dict[b] = deque([a])
    else:
        root_dict[b].append(a)
visited = [1] + [-1] * (n - 1)
done = deque([1])
while done:
    x = done.popleft()
    while root_dict[x]:
        i = root_dict[x].popleft()
        if visited[i - 1] < 0:
            visited[i - 1] = x
            done.append(i)
if -1 in visited:
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print((visited[i]))

from collections import deque

n, m = list(map(int, input().split()))
root_dict = {}
for _ in range(m):
    a, b = list(map(int, input().split()))
    if a not in root_dict:
        root_dict[a] = [b]
    else:
        root_dict[a].append(b)
    if b not in root_dict:
        root_dict[b] = [a]
    else:
        root_dict[b].append(a)
visited = [1] + [-1] * (n - 1)
done = deque([1])
while done:
    x = done.popleft()
    for i in root_dict[x]:
        if visited[i - 1] < 0:
            visited[i - 1] = x
            done.append(i)
if -1 in visited:
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print((visited[i]))

-        root_dict[a] = deque([b]) +        root_dict[a] = [b] -        root_dict[b] = deque([a]) +        root_dict[b] = [a] -    while root_dict[x]: -        i = root_dict[x].popleft() +    for i in root_dict[x]: