N,M=list(map(int, input().split()))

G=[[] for _ in range(N)]

for i in range(M):

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

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

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



siru=[-1]*(N-1)#2~~N

que=[0]



while len(que)>0:

    #print(que)

    now=que.pop(0)

    nexlist=G[now]

    for nex in nexlist:

        if nex==0:

            continue

        if siru[nex-1]==-1:

            siru[nex-1]=now

            que.append(nex)

X=siru.count(-1)

if X>=1:

    print("No")

else:

    print("Yes")

    for num in siru:

        print((num+1))

from collections import deque

N,M=list(map(int, input().split()))

G=[[] for _ in range(N)]

for i in range(M):

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

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

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



siru=[-1]*(N-1)#2~~N

que=deque([0])



while que:

    #print(que)

    now=que.popleft()

    nexlist=G[now]

    for nex in nexlist:

        if nex==0:

            continue

        if siru[nex-1]==-1:

            siru[nex-1]=now

            que.append(nex)

X=siru.count(-1)

if X>=1:

    print("No")

else:

    print("Yes")

    for num in siru:

        print((num+1))

N, M = list(map(int, input().split()))
G = [[] for _ in range(N)]
for i in range(M):
    a, b = list(map(int, input().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
siru = [-1] * (N - 1)  # 2~~N
que = [0]
while len(que) > 0:
    # print(que)
    now = que.pop(0)
    nexlist = G[now]
    for nex in nexlist:
        if nex == 0:
            continue
        if siru[nex - 1] == -1:
            siru[nex - 1] = now
            que.append(nex)
X = siru.count(-1)
if X >= 1:
    print("No")
else:
    print("Yes")
    for num in siru:
        print((num + 1))

from collections import deque

N, M = list(map(int, input().split()))
G = [[] for _ in range(N)]
for i in range(M):
    a, b = list(map(int, input().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
siru = [-1] * (N - 1)  # 2~~N
que = deque([0])
while que:
    # print(que)
    now = que.popleft()
    nexlist = G[now]
    for nex in nexlist:
        if nex == 0:
            continue
        if siru[nex - 1] == -1:
            siru[nex - 1] = now
            que.append(nex)
X = siru.count(-1)
if X >= 1:
    print("No")
else:
    print("Yes")
    for num in siru:
        print((num + 1))

+from collections import deque + -que = [0] -while len(que) > 0: +que = deque([0]) +while que: -    now = que.pop(0) +    now = que.popleft()