n, m = map(int, input().split())
g = [[] for _ in range(n)]
s = [0] + [-1 for _ in range(n-1)]

for i in range(m):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
    
def search(v):
    for i in g[v]:
        if s[i] == -1:
            s[i] = v
    for i in g[v]:
        if s[i] == v:
            search(i)

search(0)
print("Yes")
for i in s[1:]: print(i+1)