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



AB = [tuple(map(int,input().split())) for i in range(M)]



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

for a, b in AB:

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

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



ans = [-1] * N

ans[0] = 0



import queue

que = queue.Queue()

que.put(0)



while que.qsize():

    s = que.get()

    for v in es[s]:

        if ans[v] == -1:

            ans[v] = s+1

            que.put(v)



print("Yes")

print(*ans[1:], sep="\n")

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



AB = [tuple(map(int,input().split())) for i in range(M)]



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

for a, b in AB:

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

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



ans = [-1] * N

ans[0] = 0



from collections import deque

que = deque([0])



while que:

    s = que.popleft()

    for v in es[s]:

        if ans[v] == -1:

            ans[v] = s+1

            que.append(v)



print("Yes")

print(*ans[1:], sep="\n")

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for a, b in AB:
    es[a - 1].append(b - 1)
    es[b - 1].append(a - 1)
ans = [-1] * N
ans[0] = 0
import queue

que = queue.Queue()
que.put(0)
while que.qsize():
    s = que.get()
    for v in es[s]:
        if ans[v] == -1:
            ans[v] = s + 1
            que.put(v)
print("Yes")
print(*ans[1:], sep="\n")

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for a, b in AB:
    es[a - 1].append(b - 1)
    es[b - 1].append(a - 1)
ans = [-1] * N
ans[0] = 0
from collections import deque

que = deque([0])
while que:
    s = que.popleft()
    for v in es[s]:
        if ans[v] == -1:
            ans[v] = s + 1
            que.append(v)
print("Yes")
print(*ans[1:], sep="\n")

-import queue +from collections import deque -que = queue.Queue() -que.put(0) -while que.qsize(): -    s = que.get() +que = deque([0]) +while que: +    s = que.popleft() -            que.put(v) +            que.append(v)