from collections import deque



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

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



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

for a, b in ab:

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

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



q = deque()

q.append(0)

b = [0] * n

while q:

    r = q.popleft()

    for i in g[r]:

        if b[i] != 0:

            continue

        if i == 0:

            continue

        b[i] = r + 1

        q.append(i)



for i in b[1:]:

    if i == 0:

        print("No")

        exit()

print("Yes")

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

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
g = [[] for _ in range(n)]
for a, b in ab:
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
q = deque()
q.append(0)
b = [0] * n
while q:
    r = q.popleft()
    for i in g[r]:
        if b[i] != 0:
            continue
        if i == 0:
            continue
        b[i] = r + 1
        q.append(i)
for i in b[1:]:
    if i == 0:
        print("No")
        exit()
print("Yes")
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")

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