import numpy as np

import scipy.sparse as sps

import scipy.misc as spm

import collections as col

import functools as func

import itertools as ite

import fractions as frac

import math as ma

import copy as cp

import sys

def sinput(): return sys.stdin.readline()

def iinput(): return int(sinput())

def imap(): return list(map(int, sinput().split()))

def fmap(): return list(map(float, sinput().split()))

def iarr(): return list(map())

def farr(): return list(fmap())

def sarr(): return sinput().split()



#標準入力

n,m = map()

ab = np.array([iarr() for i in range(m)])

a,b = ab.T[0]-1, ab.T[1]-1



#隣接行列はnumpy使うな

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

for aa,bb in zip(a,b):

    g[aa].append(bb)

    g[bb].append(aa)





anss = [0]*n

know = [0]*n; know[0] = 1

q = col.deque([0])

while q:

    now = q.popleft()

    for next in g[now]:

        if know[next]: continue

        else: know[next] = 1; anss[next] = now; q.append(next)



print('Yes')

for ans in anss[1:]: print((ans+1))







import numpy as np

import scipy.sparse as sps

import scipy.misc as spm

import collections as col

import functools as func

import itertools as ite

import fractions as frac

import math as ma

import copy as cp

import sys

def sinput(): return sys.stdin.readline()

def iinput(): return int(sinput())

def imap(): return list(map(int, sinput().split()))

def fmap(): return list(map(float, sinput().split()))

def iarr(n=0):

    if n: return [0 for _ in range(n)]

    else: return list(map())

def farr(): return list(fmap())

def sarr(n=0):

    if n: return ["" for _ in range(n)]

    else: return sinput().split()

def barr(n): return [False for _ in range(n)]





n,m = map()

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

for i in range(m):

    a,b = map()

    g[a].append(b)

    g[b].append(a)



q = col.deque([1])

know = barr(n+1); know[1] = True

anss = iarr(n+1)

while q:

    now = q.popleft()

    for next in g[now]:

        if know[next]: continue

        else: know[next] = True; q.append(next); anss[next] = now



print("Yes")

for ans in anss[2:]: print(ans)

import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys


def sinput():
    return sys.stdin.readline()


def iinput():
    return int(sinput())


def imap():
    return list(map(int, sinput().split()))


def fmap():
    return list(map(float, sinput().split()))


def iarr():
    return list(map())


def farr():
    return list(fmap())


def sarr():
    return sinput().split()


# 標準入力
n, m = map()
ab = np.array([iarr() for i in range(m)])
a, b = ab.T[0] - 1, ab.T[1] - 1
# 隣接行列はnumpy使うな
g = [[] for i in range(n)]
for aa, bb in zip(a, b):
    g[aa].append(bb)
    g[bb].append(aa)
anss = [0] * n
know = [0] * n
know[0] = 1
q = col.deque([0])
while q:
    now = q.popleft()
    for next in g[now]:
        if know[next]:
            continue
        else:
            know[next] = 1
            anss[next] = now
            q.append(next)
print("Yes")
for ans in anss[1:]:
    print((ans + 1))

import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys


def sinput():
    return sys.stdin.readline()


def iinput():
    return int(sinput())


def imap():
    return list(map(int, sinput().split()))


def fmap():
    return list(map(float, sinput().split()))


def iarr(n=0):
    if n:
        return [0 for _ in range(n)]
    else:
        return list(map())


def farr():
    return list(fmap())


def sarr(n=0):
    if n:
        return ["" for _ in range(n)]
    else:
        return sinput().split()


def barr(n):
    return [False for _ in range(n)]


n, m = map()
g = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map()
    g[a].append(b)
    g[b].append(a)
q = col.deque([1])
know = barr(n + 1)
know[1] = True
anss = iarr(n + 1)
while q:
    now = q.popleft()
    for next in g[now]:
        if know[next]:
            continue
        else:
            know[next] = True
            q.append(next)
            anss[next] = now
print("Yes")
for ans in anss[2:]:
    print(ans)

-def iarr(): -    return list(map()) +def iarr(n=0): +    if n: +        return [0 for _ in range(n)] +    else: +        return list(map()) -def sarr(): -    return sinput().split() +def sarr(n=0): +    if n: +        return ["" for _ in range(n)] +    else: +        return sinput().split() -# 標準入力 +def barr(n): +    return [False for _ in range(n)] + + -ab = np.array([iarr() for i in range(m)]) -a, b = ab.T[0] - 1, ab.T[1] - 1 -# 隣接行列はnumpy使うな -g = [[] for i in range(n)] -for aa, bb in zip(a, b): -    g[aa].append(bb) -    g[bb].append(aa) -anss = [0] * n -know = [0] * n -know[0] = 1 -q = col.deque([0]) +g = [[] for i in range(n + 1)] +for i in range(m): +    a, b = map() +    g[a].append(b) +    g[b].append(a) +q = col.deque([1]) +know = barr(n + 1) +know[1] = True +anss = iarr(n + 1) -            know[next] = 1 +            know[next] = True +            q.append(next) -            q.append(next) -for ans in anss[1:]: -    print((ans + 1)) +for ans in anss[2:]: +    print(ans)