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

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

for i in range(m):

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

    a,b = a-1,b-1

    map_li[a].append(b)

    map_li[b].append(a)



ans_li = [-1]*n

queue=[0]

visited = [False]*n



while queue:

    x = queue.pop(0)

    for g in map_li[x]:

        if visited[g]==False:

            queue.append(g)

            if ans_li[g]==-1:

                ans_li[g]=x

                visited[g]=True 

if -1 in ans_li[1:]:

    print('No')

else:

    print('Yes')

    for ans in ans_li[1:]:

        print((ans+1))
from collections import deque

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

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

for i in range(m):

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

    a,b = a-1,b-1

    map_li[a].append(b)

    map_li[b].append(a)



ans_li = [-1]*n

queue=deque([0])

visited = [False]*n



while queue:

    x = queue.popleft()

    for g in map_li[x]:

        if visited[g]==False:

            queue.append(g)

            if ans_li[g]==-1:

                ans_li[g]=x

                visited[g]=True 

if -1 in ans_li[1:]:

    print('No')

else:

    print('Yes')

    for ans in ans_li[1:]:

        print((ans+1))

n, m = list(map(int, input().split()))
map_li = [[] for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    map_li[a].append(b)
    map_li[b].append(a)
ans_li = [-1] * n
queue = [0]
visited = [False] * n
while queue:
    x = queue.pop(0)
    for g in map_li[x]:
        if visited[g] == False:
            queue.append(g)
            if ans_li[g] == -1:
                ans_li[g] = x
                visited[g] = True
if -1 in ans_li[1:]:
    print("No")
else:
    print("Yes")
    for ans in ans_li[1:]:
        print((ans + 1))

from collections import deque

n, m = list(map(int, input().split()))
map_li = [[] for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    map_li[a].append(b)
    map_li[b].append(a)
ans_li = [-1] * n
queue = deque([0])
visited = [False] * n
while queue:
    x = queue.popleft()
    for g in map_li[x]:
        if visited[g] == False:
            queue.append(g)
            if ans_li[g] == -1:
                ans_li[g] = x
                visited[g] = True
if -1 in ans_li[1:]:
    print("No")
else:
    print("Yes")
    for ans in ans_li[1:]:
        print((ans + 1))

+from collections import deque + -queue = [0] +queue = deque([0]) -    x = queue.pop(0) +    x = queue.popleft()