from collections import deque







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

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

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

dist = [-1 for _ in range(n)]

dist[0] = 0

ans = [-1 for _ in range(n)]

qn = deque([1])

for i in range(m):

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

    a,b = min(a,b),max(a,b)

    ab[i] = [a,b]

    kr[a-1].append(b)

    kr[b-1].append(a)



dis = 1

while len(qn) > 0:

    v = qn.popleft()

    d = dist[v-1]

    for w in kr[v-1]:

        if dist[w-1] > -1:

            continue

        dist[w-1] = d + 1

        qn.append(w)

        ans[w-1] = v





#print(dist)



#ab.sort()

#print(ab)

#print(kr)



print('Yes')

for i in range(1,n):

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



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

ab = [list(map(int,input().split())) for _ in range(m)]

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

for a,b in ab:

    conn[a-1].append(b)

    conn[b-1].append(a)

q = deque([1])

#for x in conn[0]:

#    q.append(x)

ans = [-1 for _ in range(n)]

depth = ans[:]

depth[0] = 0

while q:

    v = q.popleft()

    d = depth[v-1]

    #print(v)

    for w in conn[v-1]:

        if depth[w-1] != -1:

            continue

        depth[w-1] = d + 1

        ans[w-1] = v

        q.append(w)

        #print(v,w,d)



print('Yes')

for i in range(1,n):

    print((ans[i]))

#print(conn)
from collections import deque

n, m = list(map(int, input().split()))
ab = [[] for _ in range(m)]
kr = [[] for _ in range(n)]
dist = [-1 for _ in range(n)]
dist[0] = 0
ans = [-1 for _ in range(n)]
qn = deque([1])
for i in range(m):
    a, b = list(map(int, input().split()))
    a, b = min(a, b), max(a, b)
    ab[i] = [a, b]
    kr[a - 1].append(b)
    kr[b - 1].append(a)
dis = 1
while len(qn) > 0:
    v = qn.popleft()
    d = dist[v - 1]
    for w in kr[v - 1]:
        if dist[w - 1] > -1:
            continue
        dist[w - 1] = d + 1
        qn.append(w)
        ans[w - 1] = v
# print(dist)
# ab.sort()
# print(ab)
# print(kr)
print("Yes")
for i in range(1, n):
    print((ans[i]))

from collections import deque

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
conn = [[] for _ in range(n)]
for a, b in ab:
    conn[a - 1].append(b)
    conn[b - 1].append(a)
q = deque([1])
# for x in conn[0]:
#    q.append(x)
ans = [-1 for _ in range(n)]
depth = ans[:]
depth[0] = 0
while q:
    v = q.popleft()
    d = depth[v - 1]
    # print(v)
    for w in conn[v - 1]:
        if depth[w - 1] != -1:
            continue
        depth[w - 1] = d + 1
        ans[w - 1] = v
        q.append(w)
        # print(v,w,d)
print("Yes")
for i in range(1, n):
    print((ans[i]))
# print(conn)

-ab = [[] for _ in range(m)] -kr = [[] for _ in range(n)] -dist = [-1 for _ in range(n)] -dist[0] = 0 +ab = [list(map(int, input().split())) for _ in range(m)] +conn = [[] for _ in range(n)] +for a, b in ab: +    conn[a - 1].append(b) +    conn[b - 1].append(a) +q = deque([1]) +# for x in conn[0]: +#    q.append(x) -qn = deque([1]) -for i in range(m): -    a, b = list(map(int, input().split())) -    a, b = min(a, b), max(a, b) -    ab[i] = [a, b] -    kr[a - 1].append(b) -    kr[b - 1].append(a) -dis = 1 -while len(qn) > 0: -    v = qn.popleft() -    d = dist[v - 1] -    for w in kr[v - 1]: -        if dist[w - 1] > -1: +depth = ans[:] +depth[0] = 0 +while q: +    v = q.popleft() +    d = depth[v - 1] +    # print(v) +    for w in conn[v - 1]: +        if depth[w - 1] != -1: -        dist[w - 1] = d + 1 -        qn.append(w) +        depth[w - 1] = d + 1 -# print(dist) -# ab.sort() -# print(ab) -# print(kr) +        q.append(w) +        # print(v,w,d) +# print(conn)