from math import floor,ceil,sqrt

import fractions

from collections import deque

import itertools

from collections import deque

import heapq

N,M=list(map(int,input().split()))

tree=[[] for _ in range(N)]

for i in range(M):

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

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

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

d=[float("inf") for _ in range(N)]

d[0]=0

q=[]

prev=[-1]*N

q.append([0,0])

q1=q

flag=1

#print(q)

heapq.heapify(q)

#print(q1)

while len(q)>0:

    dist,u=heapq.heappop(q)

    if d[u]<dist: continue

    for i in tree[u]:

        alt=d[u]+1

        if d[i]>alt:

            d[i]=alt

            prev[i]=u

            heapq.heappush(q,[alt,i])

    #print(prev,d,q1)

for i in range(1,N):

    if prev[i]==-1:

        flag=0

        break

if flag==0:

    print("No")

else:

    print("Yes")

    for i in range(1,N):

        print((prev[i]+1))







from math import floor,ceil,sqrt

import fractions

import itertools

from collections import deque

import heapq

N,M=list(map(int,input().split()))

tree=[[] for _ in range(N)]

for i in range(M):

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

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

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

prev=[-1]*N

d=[float("inf")]

prev[0]=0

d=deque()

d.append(0)

while len(d)>0:

    v=d.popleft()

    for i in tree[v]:

        if prev[i]==-1:

            prev[i]=v

            d.append(i)

print("Yes")

for i in range(1,N):

    print((prev[i]+1))





from math import floor, ceil, sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import heapq

N, M = list(map(int, input().split()))
tree = [[] for _ in range(N)]
for i in range(M):
    a, b = list(map(int, input().split()))
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
d = [float("inf") for _ in range(N)]
d[0] = 0
q = []
prev = [-1] * N
q.append([0, 0])
q1 = q
flag = 1
# print(q)
heapq.heapify(q)
# print(q1)
while len(q) > 0:
    dist, u = heapq.heappop(q)
    if d[u] < dist:
        continue
    for i in tree[u]:
        alt = d[u] + 1
        if d[i] > alt:
            d[i] = alt
            prev[i] = u
            heapq.heappush(q, [alt, i])
    # print(prev,d,q1)
for i in range(1, N):
    if prev[i] == -1:
        flag = 0
        break
if flag == 0:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print((prev[i] + 1))

from math import floor, ceil, sqrt
import fractions
import itertools
from collections import deque
import heapq

N, M = list(map(int, input().split()))
tree = [[] for _ in range(N)]
for i in range(M):
    a, b = list(map(int, input().split()))
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
prev = [-1] * N
d = [float("inf")]
prev[0] = 0
d = deque()
d.append(0)
while len(d) > 0:
    v = d.popleft()
    for i in tree[v]:
        if prev[i] == -1:
            prev[i] = v
            d.append(i)
print("Yes")
for i in range(1, N):
    print((prev[i] + 1))

-from collections import deque -d = [float("inf") for _ in range(N)] -d[0] = 0 -q = [] -q.append([0, 0]) -q1 = q -flag = 1 -# print(q) -heapq.heapify(q) -# print(q1) -while len(q) > 0: -    dist, u = heapq.heappop(q) -    if d[u] < dist: -        continue -    for i in tree[u]: -        alt = d[u] + 1 -        if d[i] > alt: -            d[i] = alt -            prev[i] = u -            heapq.heappush(q, [alt, i]) -    # print(prev,d,q1) +d = [float("inf")] +prev[0] = 0 +d = deque() +d.append(0) +while len(d) > 0: +    v = d.popleft() +    for i in tree[v]: +        if prev[i] == -1: +            prev[i] = v +            d.append(i) +print("Yes") -    if prev[i] == -1: -        flag = 0 -        break -if flag == 0: -    print("No") -else: -    print("Yes") -    for i in range(1, N): -        print((prev[i] + 1)) +    print((prev[i] + 1))