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

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

for c in range(m):

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

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

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



ans_list=[-1]*n



queue=[0]



while queue:

    qi=queue.pop(0)

    for gi in g[qi]:

        if ans_list[gi]==-1:

            queue.append(gi)

            ans_list[gi]=qi



print("Yes")

for ans in ans_list[1:]:

    print((ans+1))
n,m=list(map(int,input().split()))

r=[[] for x in range(n)]

for c in range(m):

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

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

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

s=[-1]*n

u=[0]

v=[]

k=1

while k<n:

    for d in u:

        for e in r[d]:

            if s[e]==-1:

                s[e]=d

                k+=1

                v.append(e)

    u=v

print('Yes')

for c in range(n-1):

    print((s[c+1]+1))
n, m = list(map(int, input().split()))
g = [[] for x in range(n)]
for c in range(m):
    a, b = list(map(int, input().split()))
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
ans_list = [-1] * n
queue = [0]
while queue:
    qi = queue.pop(0)
    for gi in g[qi]:
        if ans_list[gi] == -1:
            queue.append(gi)
            ans_list[gi] = qi
print("Yes")
for ans in ans_list[1:]:
    print((ans + 1))

n, m = list(map(int, input().split()))
r = [[] for x in range(n)]
for c in range(m):
    a, b = list(map(int, input().split()))
    r[a - 1].append(b - 1)
    r[b - 1].append(a - 1)
s = [-1] * n
u = [0]
v = []
k = 1
while k < n:
    for d in u:
        for e in r[d]:
            if s[e] == -1:
                s[e] = d
                k += 1
                v.append(e)
    u = v
print("Yes")
for c in range(n - 1):
    print((s[c + 1] + 1))

-g = [[] for x in range(n)] +r = [[] for x in range(n)] -    g[a - 1].append(b - 1) -    g[b - 1].append(a - 1) -ans_list = [-1] * n -queue = [0] -while queue: -    qi = queue.pop(0) -    for gi in g[qi]: -        if ans_list[gi] == -1: -            queue.append(gi) -            ans_list[gi] = qi +    r[a - 1].append(b - 1) +    r[b - 1].append(a - 1) +s = [-1] * n +u = [0] +v = [] +k = 1 +while k < n: +    for d in u: +        for e in r[d]: +            if s[e] == -1: +                s[e] = d +                k += 1 +                v.append(e) +    u = v -for ans in ans_list[1:]: -    print((ans + 1)) +for c in range(n - 1): +    print((s[c + 1] + 1))