# ダイクストラ法で部屋1から各部屋への最短経路を出す

import queue



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

edges = [list(map(int, input().split())) for _ in range(m)]



# 隣接行列の作成

edges_dict = {}

for edge in edges:

    a, b = edge



    if a not in edges_dict:

        edges_dict[a] = [b]

    else:

        edges_dict[a].append(b)



    if b not in edges_dict:

        edges_dict[b] = [a]

    else:

        edges_dict[b].append(a)



# 定数 

COST = 1

INF = 1e10



# i=0は未使用, i>0は部屋iへの最短距離

dist_list = [INF] * (n + 1)

# i=0は未使用, i>0は部屋iの最短経路がたどる次の部屋 = 道しるべ

prev_list = [None] * (n + 1)

q = queue.PriorityQueue()



# 初期化

q.put((0, 1)) # (最短経路, 部屋番号)

dist_list[1] = 0

prev_list[1] = 1



while not q.empty():

    min_dist, v = q.get()

    #print("min_dist={}, v={}".format(min_dist, v))



    if dist_list[v] < min_dist:

        #print("waste")

        continue



    #print("check edges: ", edges_dict[v])

    for w in edges_dict[v]:

        cost = dist_list[v] + COST

        if dist_list[w] > cost:

            #print("push path {} -> {}; cost {}; path {}".format(v, w, cost, prev_list[v]))

            dist_list[w] = cost

            prev_list[w] = v#prev_list[v]

            q.put((cost, w))



print("Yes")

#print(edges_dict)

#print(dist_list)

#print(prev_list)

for v in prev_list[2:]:

    print(v)

# ダイクストラ法で部屋1から各部屋への最短経路を出す

import queue



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

edges = [list(map(int, input().split())) for _ in range(m)]



# 隣接行列の作成

edges_dict = {}

for edge in edges:

    a, b = edge



    if a not in edges_dict:

        edges_dict[a] = [b]

    else:

        edges_dict[a].append(b)



    if b not in edges_dict:

        edges_dict[b] = [a]

    else:

        edges_dict[b].append(a)



# i=0は未使用, i>0は部屋iの最短経路がたどる次の部屋 = 道しるべ

prev_list = [None] * (n + 1)

q = queue.Queue()



# 初期化

q.put(1)

prev_list[1] = 1



while not q.empty():

    v = q.get()

    for w in edges_dict[v]:

        if prev_list[w] is None:

            prev_list[w] = v

            q.put(w)



print("Yes")

for v in prev_list[2:]:

    print(v)

# ダイクストラ法で部屋1から各部屋への最短経路を出す
import queue

n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]
# 隣接行列の作成
edges_dict = {}
for edge in edges:
    a, b = edge
    if a not in edges_dict:
        edges_dict[a] = [b]
    else:
        edges_dict[a].append(b)
    if b not in edges_dict:
        edges_dict[b] = [a]
    else:
        edges_dict[b].append(a)
# 定数
COST = 1
INF = 1e10
# i=0は未使用, i>0は部屋iへの最短距離
dist_list = [INF] * (n + 1)
# i=0は未使用, i>0は部屋iの最短経路がたどる次の部屋 = 道しるべ
prev_list = [None] * (n + 1)
q = queue.PriorityQueue()
# 初期化
q.put((0, 1))  # (最短経路, 部屋番号)
dist_list[1] = 0
prev_list[1] = 1
while not q.empty():
    min_dist, v = q.get()
    # print("min_dist={}, v={}".format(min_dist, v))
    if dist_list[v] < min_dist:
        # print("waste")
        continue
    # print("check edges: ", edges_dict[v])
    for w in edges_dict[v]:
        cost = dist_list[v] + COST
        if dist_list[w] > cost:
            # print("push path {} -> {}; cost {}; path {}".format(v, w, cost, prev_list[v]))
            dist_list[w] = cost
            prev_list[w] = v  # prev_list[v]
            q.put((cost, w))
print("Yes")
# print(edges_dict)
# print(dist_list)
# print(prev_list)
for v in prev_list[2:]:
    print(v)

# ダイクストラ法で部屋1から各部屋への最短経路を出す
import queue

n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]
# 隣接行列の作成
edges_dict = {}
for edge in edges:
    a, b = edge
    if a not in edges_dict:
        edges_dict[a] = [b]
    else:
        edges_dict[a].append(b)
    if b not in edges_dict:
        edges_dict[b] = [a]
    else:
        edges_dict[b].append(a)
# i=0は未使用, i>0は部屋iの最短経路がたどる次の部屋 = 道しるべ
prev_list = [None] * (n + 1)
q = queue.Queue()
# 初期化
q.put(1)
prev_list[1] = 1
while not q.empty():
    v = q.get()
    for w in edges_dict[v]:
        if prev_list[w] is None:
            prev_list[w] = v
            q.put(w)
print("Yes")
for v in prev_list[2:]:
    print(v)

-# 定数 -COST = 1 -INF = 1e10 -# i=0は未使用, i>0は部屋iへの最短距離 -dist_list = [INF] * (n + 1) -q = queue.PriorityQueue() +q = queue.Queue() -q.put((0, 1))  # (最短経路, 部屋番号) -dist_list[1] = 0 +q.put(1) -    min_dist, v = q.get() -    # print("min_dist={}, v={}".format(min_dist, v)) -    if dist_list[v] < min_dist: -        # print("waste") -        continue -    # print("check edges: ", edges_dict[v]) +    v = q.get() -        cost = dist_list[v] + COST -        if dist_list[w] > cost: -            # print("push path {} -> {}; cost {}; path {}".format(v, w, cost, prev_list[v])) -            dist_list[w] = cost -            prev_list[w] = v  # prev_list[v] -            q.put((cost, w)) +        if prev_list[w] is None: +            prev_list[w] = v +            q.put(w) -# print(edges_dict) -# print(dist_list) -# print(prev_list)