import sys

from collections import deque



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

link = [ [] for i in range(n)]

for i in sys.stdin.readlines():

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

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

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



d = deque([0])

ans = [-1]*n

ans[0] = 0

while d:

    p = d.popleft()

    for v in link[p]:

        if ans[v] == -1:

            ans[v] = p+1

            d.append(v)



if -1 in ans:

    print("No")

else:

    print("Yes")

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

import sys

from collections import deque



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

link = [ [] for i in range(n)]

for i in sys.stdin.readlines():

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

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

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



d = deque([0])

ans = [-1]*n

ans[0] = 0

while d:

    p = d.pop()

    for v in link[p]:

        if ans[v] == -1:

            ans[v] = p+1

            d.appendleft(v)



if -1 in ans:

    print("No")

else:

    print("Yes")

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

import sys
from collections import deque

n, m = map(int, input().split())
link = [[] for i in range(n)]
for i in sys.stdin.readlines():
    a, b = map(int, i.split())
    link[a - 1].append(b - 1)
    link[b - 1].append(a - 1)
d = deque([0])
ans = [-1] * n
ans[0] = 0
while d:
    p = d.popleft()
    for v in link[p]:
        if ans[v] == -1:
            ans[v] = p + 1
            d.append(v)
if -1 in ans:
    print("No")
else:
    print("Yes")
    print(*ans[1:], sep="\n")

import sys
from collections import deque

n, m = map(int, input().split())
link = [[] for i in range(n)]
for i in sys.stdin.readlines():
    a, b = map(int, i.split())
    link[a - 1].append(b - 1)
    link[b - 1].append(a - 1)
d = deque([0])
ans = [-1] * n
ans[0] = 0
while d:
    p = d.pop()
    for v in link[p]:
        if ans[v] == -1:
            ans[v] = p + 1
            d.appendleft(v)
if -1 in ans:
    print("No")
else:
    print("Yes")
    print(*ans[1:], sep="\n")

-    p = d.popleft() +    p = d.pop() -            d.append(v) +            d.appendleft(v)