from collections import deque

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

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

flag = [False for i in range(n)]



for i in range(m):

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

    rootlist[a-1].append(b)

    rootlist[b-1].append(a)



que = deque()

que.append(1)

while len(que) !=0:

    now = que.popleft()

    for room in rootlist[now-1]:

        if flag[room-1] == False:

            flag[room-1] = now

            que.append(room)



print('Yes')

for root in flag[1:]:

    print(root)
from collections import deque

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

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

flag = [False]*n



for i in range(m):

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

    rootlist[a-1].append(b)

    rootlist[b-1].append(a)



que = deque([1])

while que:

    now = que.popleft()

    for room in rootlist[now-1]:

        if flag[room-1] == False:

            flag[room-1] = now

            que.append(room)



print('Yes')

for root in flag[1:]:

    print(root)
from collections import deque

n, m = list(map(int, input().split()))
rootlist = [[] for i in range(n)]
flag = [False for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    rootlist[a - 1].append(b)
    rootlist[b - 1].append(a)
que = deque()
que.append(1)
while len(que) != 0:
    now = que.popleft()
    for room in rootlist[now - 1]:
        if flag[room - 1] == False:
            flag[room - 1] = now
            que.append(room)
print("Yes")
for root in flag[1:]:
    print(root)

from collections import deque

n, m = list(map(int, input().split()))
rootlist = [[] for i in range(n)]
flag = [False] * n
for i in range(m):
    a, b = list(map(int, input().split()))
    rootlist[a - 1].append(b)
    rootlist[b - 1].append(a)
que = deque([1])
while que:
    now = que.popleft()
    for room in rootlist[now - 1]:
        if flag[room - 1] == False:
            flag[room - 1] = now
            que.append(room)
print("Yes")
for root in flag[1:]:
    print(root)

-flag = [False for i in range(n)] +flag = [False] * n -que = deque() -que.append(1) -while len(que) != 0: +que = deque([1]) +while que: