from collections import deque



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

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

for i in range(m):

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

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

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



q = deque([0])

b = [0] * n

while q:

    x = q.popleft()

    for i in g[x]:

        if b[i] != 0:

            continue

        b[i] = x + 1

        q.append(i)



if 0 in b[1:]:

    print("No")

else:

    print("Yes")

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

from collections import deque



print("Yes")



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

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

for i in range(m):

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

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

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



q = deque([0])

b = [0] * n

while q:

    x = q.popleft()

    for i in g[x]:

        if b[i] != 0:

            continue

        b[i] = x + 1

        q.append(i)



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

from collections import deque

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
q = deque([0])
b = [0] * n
while q:
    x = q.popleft()
    for i in g[x]:
        if b[i] != 0:
            continue
        b[i] = x + 1
        q.append(i)
if 0 in b[1:]:
    print("No")
else:
    print("Yes")
    print(*b[1:], sep="\n")

from collections import deque

print("Yes")
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
q = deque([0])
b = [0] * n
while q:
    x = q.popleft()
    for i in g[x]:
        if b[i] != 0:
            continue
        b[i] = x + 1
        q.append(i)
print(*b[1:], sep="\n")

+print("Yes") -if 0 in b[1:]: -    print("No") -else: -    print("Yes") -    print(*b[1:], sep="\n") +print(*b[1:], sep="\n")