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

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

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

ans = [0]*n



ans[0]=1



for i in range(m):

    ikeruheya[a[i][0]-1].append(a[i][1])

    ikeruheya[a[i][1]-1].append(a[i][0])





next=[1]



while len(next):

    imaheya = next.pop(0)-1

    for j in range(len(ikeruheya[imaheya])):

        if ans[ikeruheya[imaheya][j]-1]==0:

            ans[ikeruheya[imaheya][j]-1]= imaheya + 1           

            next.append(ikeruheya[imaheya][j])

            #ikeruheya[[imaheya-1][j]-1].remove(imaheya)

        



print("Yes")

for i in range(1, n):

    print((ans[i]))





#b=ikeruheya

#michi=ans

#heya=next

#now=imaheya-1

    

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

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

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

ans = [0]*(n+1)



ans[0]=-1

ans[1]=1

for i in range(m):

    if a[i][0]==1:

        ikeruheya[0].append(a[i][1])

    elif a[i][1]==1:

        ikeruheya[0].append(a[i][0])

    else:

        ikeruheya[a[i][0]-1].append(a[i][1])

        ikeruheya[a[i][1]-1].append(a[i][0])



#print(ikeruheya)

next=[1]

count = 1

while count < n and len(next)!=0:

    

    imaheya = next.pop(0)

    j = 0

    while j < len(ikeruheya[imaheya-1]) and count < n:

    

        if ans[ikeruheya[imaheya-1][j]]==0:

            ans[ikeruheya[imaheya-1][j]]= imaheya             

            next.append(ikeruheya[imaheya-1][j])

            count += 1

            j+=1

        else:

            j+=1





print("Yes")

for i in range(2, n+1):

    print((ans[i]))





    

    

n, m = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(m)]
ikeruheya = [[] for i in range(n)]
ans = [0] * n
ans[0] = 1
for i in range(m):
    ikeruheya[a[i][0] - 1].append(a[i][1])
    ikeruheya[a[i][1] - 1].append(a[i][0])
next = [1]
while len(next):
    imaheya = next.pop(0) - 1
    for j in range(len(ikeruheya[imaheya])):
        if ans[ikeruheya[imaheya][j] - 1] == 0:
            ans[ikeruheya[imaheya][j] - 1] = imaheya + 1
            next.append(ikeruheya[imaheya][j])
            # ikeruheya[[imaheya-1][j]-1].remove(imaheya)
print("Yes")
for i in range(1, n):
    print((ans[i]))
# b=ikeruheya
# michi=ans
# heya=next
# now=imaheya-1

n, m = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(m)]
ikeruheya = [[] for i in range(n)]
ans = [0] * (n + 1)
ans[0] = -1
ans[1] = 1
for i in range(m):
    if a[i][0] == 1:
        ikeruheya[0].append(a[i][1])
    elif a[i][1] == 1:
        ikeruheya[0].append(a[i][0])
    else:
        ikeruheya[a[i][0] - 1].append(a[i][1])
        ikeruheya[a[i][1] - 1].append(a[i][0])
# print(ikeruheya)
next = [1]
count = 1
while count < n and len(next) != 0:
    imaheya = next.pop(0)
    j = 0
    while j < len(ikeruheya[imaheya - 1]) and count < n:
        if ans[ikeruheya[imaheya - 1][j]] == 0:
            ans[ikeruheya[imaheya - 1][j]] = imaheya
            next.append(ikeruheya[imaheya - 1][j])
            count += 1
            j += 1
        else:
            j += 1
print("Yes")
for i in range(2, n + 1):
    print((ans[i]))

-ans = [0] * n -ans[0] = 1 +ans = [0] * (n + 1) +ans[0] = -1 +ans[1] = 1 -    ikeruheya[a[i][0] - 1].append(a[i][1]) -    ikeruheya[a[i][1] - 1].append(a[i][0]) +    if a[i][0] == 1: +        ikeruheya[0].append(a[i][1]) +    elif a[i][1] == 1: +        ikeruheya[0].append(a[i][0]) +    else: +        ikeruheya[a[i][0] - 1].append(a[i][1]) +        ikeruheya[a[i][1] - 1].append(a[i][0]) +# print(ikeruheya) -while len(next): -    imaheya = next.pop(0) - 1 -    for j in range(len(ikeruheya[imaheya])): -        if ans[ikeruheya[imaheya][j] - 1] == 0: -            ans[ikeruheya[imaheya][j] - 1] = imaheya + 1 -            next.append(ikeruheya[imaheya][j]) -            # ikeruheya[[imaheya-1][j]-1].remove(imaheya) +count = 1 +while count < n and len(next) != 0: +    imaheya = next.pop(0) +    j = 0 +    while j < len(ikeruheya[imaheya - 1]) and count < n: +        if ans[ikeruheya[imaheya - 1][j]] == 0: +            ans[ikeruheya[imaheya - 1][j]] = imaheya +            next.append(ikeruheya[imaheya - 1][j]) +            count += 1 +            j += 1 +        else: +            j += 1 -for i in range(1, n): +for i in range(2, n + 1): -# b=ikeruheya -# michi=ans -# heya=next -# now=imaheya-1