from collections import deque, defaultdict

import sys





def input():

    return sys.stdin.readline().strip()





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

graph = defaultdict(set)

for _ in range(M):

    A, B = map(lambda x: int(x) - 1, input().split())

    graph[A].add(B)

    graph[B].add(A)

if len(set(graph.keys())) != N:

    print('No')

    exit()



tokens = [-1] * N

tokens[0] = N

q = deque([0])

while q:

    v = q.popleft()

    for nv in graph[v]:

        if tokens[nv] < 0:

            tokens[nv] = v

            q.append(nv)



print('Yes')

[print(t + 1) for t in tokens[1:]]

from collections import deque, defaultdict

import sys





def input():

    return sys.stdin.readline().strip()





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

graph = defaultdict(set)

for _ in range(M):

    A, B = [int(x) - 1 for x in input().split()]

    graph[A].add(B)

    graph[B].add(A)



tokens = [-1] * N

tokens[0] = N

q = deque([0])

while q:

    v = q.popleft()

    for nv in graph[v]:

        if tokens[nv] < 0:

            tokens[nv] = v

            q.append(nv)



if -1 in tokens[1:]:

    print('No')

else:

    print('Yes')

    print(('\n'.join([str(x + 1) for x in tokens[1:]])))

from collections import deque, defaultdict
import sys


def input():
    return sys.stdin.readline().strip()


N, M = map(int, input().split())
graph = defaultdict(set)
for _ in range(M):
    A, B = map(lambda x: int(x) - 1, input().split())
    graph[A].add(B)
    graph[B].add(A)
if len(set(graph.keys())) != N:
    print("No")
    exit()
tokens = [-1] * N
tokens[0] = N
q = deque([0])
while q:
    v = q.popleft()
    for nv in graph[v]:
        if tokens[nv] < 0:
            tokens[nv] = v
            q.append(nv)
print("Yes")
[print(t + 1) for t in tokens[1:]]

from collections import deque, defaultdict
import sys


def input():
    return sys.stdin.readline().strip()


N, M = list(map(int, input().split()))
graph = defaultdict(set)
for _ in range(M):
    A, B = [int(x) - 1 for x in input().split()]
    graph[A].add(B)
    graph[B].add(A)
tokens = [-1] * N
tokens[0] = N
q = deque([0])
while q:
    v = q.popleft()
    for nv in graph[v]:
        if tokens[nv] < 0:
            tokens[nv] = v
            q.append(nv)
if -1 in tokens[1:]:
    print("No")
else:
    print("Yes")
    print(("\n".join([str(x + 1) for x in tokens[1:]])))

-N, M = map(int, input().split()) +N, M = list(map(int, input().split())) -    A, B = map(lambda x: int(x) - 1, input().split()) +    A, B = [int(x) - 1 for x in input().split()] -if len(set(graph.keys())) != N: -    print("No") -    exit() -print("Yes") -[print(t + 1) for t in tokens[1:]] +if -1 in tokens[1:]: +    print("No") +else: +    print("Yes") +    print(("\n".join([str(x + 1) for x in tokens[1:]])))