from sys import stdin

import math

import fractions

from collections import deque

from collections import Counter

import itertools



INF = 10 ** 10





# N個の部屋とM本の通路

N, M = [int(x) for x in stdin.readline().rstrip().split()]



route = [[] for _ in range(N+1)]



for _ in range(M):

    A, B = [int(x) for x in stdin.readline().rstrip().split()]

    route[A].append(B)

    route[B].append(A)





kyori_to_1 = [INF for _ in range(N+1)]

kyori_to_1[1] = 0



miti = [0 for _ in range(N+1)]

miti[0] = -1

miti[1] = -1



is_visited = [False for _ in range(N+1)]



# 幅優先探索

# 試すべき位置をキューで管理

que = deque([1])



# キューが空じゃなければ

while len(que) != 0:

    now = que.popleft()

    

    if is_visited[now]:

        continue



    is_visited[now] = True



    for place in route[now]:

        que.append(place)



        if kyori_to_1[now]+1 < kyori_to_1[place]:

            kyori_to_1[place] = kyori_to_1[now]+1

            miti[place] = now



if 0 in miti:

    print("No")

else:

    for i in range(1, N+1):

        if i == 1:

            print("Yes")

        else:

            print((miti[i]))

from sys import stdin

import math

import fractions

from collections import deque

from collections import Counter

import itertools



INF = 10 ** 10



# N個の部屋とM本の通路

N, M = [int(x) for x in stdin.readline().rstrip().split()]



route = [[] for _ in range(N+1)]



# A->B と B->A をリストに保存していく

# AとBは "1以上" を想定

for _ in range(M):

    A, B = [int(x) for x in stdin.readline().rstrip().split()]

    route[A].append(B)

    route[B].append(A)



# 場所1までの距離

dist_to_1 = [INF for _ in range(N+1)]

dist_to_1[1] = 0



# next_route[i] = j: 場所iがゴールに最短でたどり着くために向かう場所j

next_route = [0 for _ in range(N+1)]



# 場所iに訪れたかどうか

is_visited = [False for _ in range(N+1)]



# 幅優先探索

# 試すべき位置をキューで管理

que = deque([1])



# キューが空じゃなければ

while len(que) != 0:

    now = que.popleft()

    

    # 過去に訪れていれば無視

    if is_visited[now]:

        continue



    is_visited[now] = True



    # そこからいける場所を幅優先探索で

    for place in route[now]:

        que.append(place)



        # 距離とルートの更新

        if dist_to_1[now]+1 < dist_to_1[place]:

            dist_to_1[place] = dist_to_1[now]+1

            next_route[place] = now



# 場所2以降において、どこか次の道が見つかってない場合は

# ゴールにいけないということ

if 0 in next_route[2:]:

    print("No")

else:

    print("Yes")

    for i in range(2, N+1):

        print((next_route[i]))
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10**10
# N個の部屋とM本の通路
N, M = [int(x) for x in stdin.readline().rstrip().split()]
route = [[] for _ in range(N + 1)]
for _ in range(M):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    route[A].append(B)
    route[B].append(A)
kyori_to_1 = [INF for _ in range(N + 1)]
kyori_to_1[1] = 0
miti = [0 for _ in range(N + 1)]
miti[0] = -1
miti[1] = -1
is_visited = [False for _ in range(N + 1)]
# 幅優先探索
# 試すべき位置をキューで管理
que = deque([1])
# キューが空じゃなければ
while len(que) != 0:
    now = que.popleft()
    if is_visited[now]:
        continue
    is_visited[now] = True
    for place in route[now]:
        que.append(place)
        if kyori_to_1[now] + 1 < kyori_to_1[place]:
            kyori_to_1[place] = kyori_to_1[now] + 1
            miti[place] = now
if 0 in miti:
    print("No")
else:
    for i in range(1, N + 1):
        if i == 1:
            print("Yes")
        else:
            print((miti[i]))

from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10**10
# N個の部屋とM本の通路
N, M = [int(x) for x in stdin.readline().rstrip().split()]
route = [[] for _ in range(N + 1)]
# A->B と B->A をリストに保存していく
# AとBは "1以上" を想定
for _ in range(M):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    route[A].append(B)
    route[B].append(A)
# 場所1までの距離
dist_to_1 = [INF for _ in range(N + 1)]
dist_to_1[1] = 0
# next_route[i] = j: 場所iがゴールに最短でたどり着くために向かう場所j
next_route = [0 for _ in range(N + 1)]
# 場所iに訪れたかどうか
is_visited = [False for _ in range(N + 1)]
# 幅優先探索
# 試すべき位置をキューで管理
que = deque([1])
# キューが空じゃなければ
while len(que) != 0:
    now = que.popleft()
    # 過去に訪れていれば無視
    if is_visited[now]:
        continue
    is_visited[now] = True
    # そこからいける場所を幅優先探索で
    for place in route[now]:
        que.append(place)
        # 距離とルートの更新
        if dist_to_1[now] + 1 < dist_to_1[place]:
            dist_to_1[place] = dist_to_1[now] + 1
            next_route[place] = now
# 場所2以降において、どこか次の道が見つかってない場合は
# ゴールにいけないということ
if 0 in next_route[2:]:
    print("No")
else:
    print("Yes")
    for i in range(2, N + 1):
        print((next_route[i]))

+# A->B と B->A をリストに保存していく +# AとBは "1以上" を想定 -kyori_to_1 = [INF for _ in range(N + 1)] -kyori_to_1[1] = 0 -miti = [0 for _ in range(N + 1)] -miti[0] = -1 -miti[1] = -1 +# 場所1までの距離 +dist_to_1 = [INF for _ in range(N + 1)] +dist_to_1[1] = 0 +# next_route[i] = j: 場所iがゴールに最短でたどり着くために向かう場所j +next_route = [0 for _ in range(N + 1)] +# 場所iに訪れたかどうか +    # 過去に訪れていれば無視 +    # そこからいける場所を幅優先探索で -        if kyori_to_1[now] + 1 < kyori_to_1[place]: -            kyori_to_1[place] = kyori_to_1[now] + 1 -            miti[place] = now -if 0 in miti: +        # 距離とルートの更新 +        if dist_to_1[now] + 1 < dist_to_1[place]: +            dist_to_1[place] = dist_to_1[now] + 1 +            next_route[place] = now +# 場所2以降において、どこか次の道が見つかってない場合は +# ゴールにいけないということ +if 0 in next_route[2:]: -    for i in range(1, N + 1): -        if i == 1: -            print("Yes") -        else: -            print((miti[i])) +    print("Yes") +    for i in range(2, N + 1): +        print((next_route[i]))