import queue

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

V = [[] for _ in range(n+1)]

for _ in range(m):

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

    V[a].append(b)

    V[b].append(a)

ans = [-1]*(n+1)

q = queue.Queue()

q.put(1)

while not q.empty():

    p = q.get()

    for c in V[p]:

        if c > 1 and ans[c] < 0:

            ans[c] = p

            q.put(c)

print('Yes')

for x in ans[2:]: print(x)

from collections import deque

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

V = [[] for _ in range(n+1)]

for _ in range(m):

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

    V[a].append(b)

    V[b].append(a)

ans = [-1]*(n+1)

q = deque()

q.append(1)

while len(q):

    p = q.popleft()

    for c in V[p]:

        if c > 1 and ans[c] < 0:

            ans[c] = p

            q.append(c)

print('Yes')

for i in range(2,n+1): print((ans[i]))

import queue

n, m = list(map(int, input().split()))
V = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    V[a].append(b)
    V[b].append(a)
ans = [-1] * (n + 1)
q = queue.Queue()
q.put(1)
while not q.empty():
    p = q.get()
    for c in V[p]:
        if c > 1 and ans[c] < 0:
            ans[c] = p
            q.put(c)
print("Yes")
for x in ans[2:]:
    print(x)

from collections import deque

n, m = list(map(int, input().split()))
V = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    V[a].append(b)
    V[b].append(a)
ans = [-1] * (n + 1)
q = deque()
q.append(1)
while len(q):
    p = q.popleft()
    for c in V[p]:
        if c > 1 and ans[c] < 0:
            ans[c] = p
            q.append(c)
print("Yes")
for i in range(2, n + 1):
    print((ans[i]))

-import queue +from collections import deque -q = queue.Queue() -q.put(1) -while not q.empty(): -    p = q.get() +q = deque() +q.append(1) +while len(q): +    p = q.popleft() -            q.put(c) +            q.append(c) -for x in ans[2:]: -    print(x) +for i in range(2, n + 1): +    print((ans[i]))