from collections import deque

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

G = [[] for _ in range(n+1)]

for _ in range(m):

    u, v = list(map(int, input().split()))

    G[u].append(v)

    G[v].append(u)

q = deque([1])

p = [0]*(n+1)

while q:

    v = q.popleft()

    for u in G[v]:

        if p[u] == 0:

            p[u] = v

            q.append(u)

print(("Yes\n"+"\n".join(map(str, p[2:]))))
import sys

input = sys.stdin.readline

from collections import deque

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

G = [[] for _ in range(n+1)]

for _ in range(m):

    u, v = list(map(int, input().split()))

    G[u].append(v)

    G[v].append(u)

q = deque([1])

p = [0]*(n+1)

while q:

    v = q.popleft()

    for u in G[v]:

        if p[u] == 0:

            p[u] = v

            q.append(u)

print(("Yes\n"+"\n".join(map(str, p[2:]))))
from collections import deque

n, m = list(map(int, input().split()))
G = [[] for _ in range(n + 1)]
for _ in range(m):
    u, v = list(map(int, input().split()))
    G[u].append(v)
    G[v].append(u)
q = deque([1])
p = [0] * (n + 1)
while q:
    v = q.popleft()
    for u in G[v]:
        if p[u] == 0:
            p[u] = v
            q.append(u)
print(("Yes\n" + "\n".join(map(str, p[2:]))))

import sys

input = sys.stdin.readline
from collections import deque

n, m = list(map(int, input().split()))
G = [[] for _ in range(n + 1)]
for _ in range(m):
    u, v = list(map(int, input().split()))
    G[u].append(v)
    G[v].append(u)
q = deque([1])
p = [0] * (n + 1)
while q:
    v = q.popleft()
    for u in G[v]:
        if p[u] == 0:
            p[u] = v
            q.append(u)
print(("Yes\n" + "\n".join(map(str, p[2:]))))

+import sys + +input = sys.stdin.readline