from collections import deque

n, m = map(int, input().split())
a = [0] * m
b = [0] * m
c = [[-1] * n for i in range(n)]
lead = [0] * n
i_n = [0] * n
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    c[b[i]][i_n[b[i]]] = a[i]
    c[a[i]][i_n[a[i]]] = b[i]
    i_n[b[i]] += 1
    i_n[a[i]] += 1

d = deque()
d.append(0)

while len(d):
    k = len(d)
    for i in range(k):
        p = d[0]
        for j in range(n):
            if c[p][j] == -1:
                break
            if lead[c[p][j]] == 0:
                lead[c[p][j]] = p + 1
                d.append(c[p][j])
        d.popleft()

print('Yes')
for i in range(n - 1):
    print(lead[i + 1])
