import itertools

import math

import fractions

import functools

import copy

from collections import deque



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

g = [[] for i in range(n)]

for i in range(m):

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

    a -= 1

    b -= 1

    g[a].append(b)

    g[b].append(a)





a = [-1]*n

d = deque([0])

while d:

    f = d.popleft()

    for i in g[f]:

        if a[i] == -1:

            a[i] = f

            d.append(i)



print("Yes")

for i in range(1,n):

    print((a[i]+1))

import itertools

import math

import fractions

import functools

import copy

from collections import deque



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

ab = [[] for _ in range(n)]

for i in range(m):

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

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

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



ans = [-1] * n

d = deque([0])



while d:

    f = d.popleft()

    for i in ab[f]:

        if ans[i] == -1:

            ans[i] = f

            d.append(i)



print("Yes")

for i in range(1,n):

    print((ans[i]+1))

import itertools
import math
import fractions
import functools
import copy
from collections import deque

n, m = list(map(int, input().split()))
g = [[] for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
a = [-1] * n
d = deque([0])
while d:
    f = d.popleft()
    for i in g[f]:
        if a[i] == -1:
            a[i] = f
            d.append(i)
print("Yes")
for i in range(1, n):
    print((a[i] + 1))

import itertools
import math
import fractions
import functools
import copy
from collections import deque

n, m = list(map(int, input().split()))
ab = [[] for _ in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    ab[a - 1].append(b - 1)
    ab[b - 1].append(a - 1)
ans = [-1] * n
d = deque([0])
while d:
    f = d.popleft()
    for i in ab[f]:
        if ans[i] == -1:
            ans[i] = f
            d.append(i)
print("Yes")
for i in range(1, n):
    print((ans[i] + 1))

-g = [[] for i in range(n)] +ab = [[] for _ in range(n)] -    a -= 1 -    b -= 1 -    g[a].append(b) -    g[b].append(a) -a = [-1] * n +    ab[a - 1].append(b - 1) +    ab[b - 1].append(a - 1) +ans = [-1] * n -    for i in g[f]: -        if a[i] == -1: -            a[i] = f +    for i in ab[f]: +        if ans[i] == -1: +            ans[i] = f -    print((a[i] + 1)) +    print((ans[i] + 1))