# coding: utf-8

import sys

from heapq import heapify, heappop, heappush



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



# ダイクストラ法、自分の部屋から行けるところの中から最小の距離の部屋

N, M = lr()

graph = [[] for _ in range(N+1)]  # 1-indexed

for _ in range(M):

    a, b = lr()

    graph[a].append(b)

    graph[b].append(a)



INF = 10 ** 15



def dijkstra(start):

    dist = [INF] * (N+1)

    dist[start] = 0

    que = [(0, start)]

    while que:

        d, prev = heappop(que)

        if dist[prev] < d:

            continue

        for next in graph[prev]:

            d1 = d + 1

            if dist[next] > d1:

                dist[next] = d1

                heappush(que, (d1, next))

    return dist



dist = dijkstra(1)

if INF in dist[1:]:

    print('No'); exit()



answer = [None] * (N+1)

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

    a = INF

    for c in graph[i]:

        if dist[c] < a:

            a = dist[c]

            answer[i] = str(c)



print('Yes')

print(('\n'.join(answer[2:])))

# coding: utf-8

import sys

from collections import deque



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N, M = lr()

graph = [[] for _ in range(N+1)]  # 1-indexed

for _ in range(M):

    a, b = lr()

    graph[a].append(b)

    graph[b].append(a)



def bfs(x):

    dist = [None] * (N+1)

    que = deque([1])

    dir = [None] * (N+1)

    popleft = que.popleft; append = que.append    

    while que:

        x = popleft()

        d = dist[x]

        for next in graph[x]:

            if dir[next] != None:

                continue

            dir[next] = str(x)

            append(next)

    return dir



dir = bfs(1)

print('Yes')

print(('\n'.join(dir[2:])))

# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# ダイクストラ法、自分の部屋から行けるところの中から最小の距離の部屋
N, M = lr()
graph = [[] for _ in range(N + 1)]  # 1-indexed
for _ in range(M):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)
INF = 10**15


def dijkstra(start):
    dist = [INF] * (N + 1)
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next in graph[prev]:
            d1 = d + 1
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
    return dist


dist = dijkstra(1)
if INF in dist[1:]:
    print("No")
    exit()
answer = [None] * (N + 1)
for i in range(2, N + 1):
    a = INF
    for c in graph[i]:
        if dist[c] < a:
            a = dist[c]
            answer[i] = str(c)
print("Yes")
print(("\n".join(answer[2:])))

# coding: utf-8
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
graph = [[] for _ in range(N + 1)]  # 1-indexed
for _ in range(M):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)


def bfs(x):
    dist = [None] * (N + 1)
    que = deque([1])
    dir = [None] * (N + 1)
    popleft = que.popleft
    append = que.append
    while que:
        x = popleft()
        d = dist[x]
        for next in graph[x]:
            if dir[next] != None:
                continue
            dir[next] = str(x)
            append(next)
    return dir


dir = bfs(1)
print("Yes")
print(("\n".join(dir[2:])))

-from heapq import heapify, heappop, heappush +from collections import deque -# ダイクストラ法、自分の部屋から行けるところの中から最小の距離の部屋 -INF = 10**15 -def dijkstra(start): -    dist = [INF] * (N + 1) -    dist[start] = 0 -    que = [(0, start)] +def bfs(x): +    dist = [None] * (N + 1) +    que = deque([1]) +    dir = [None] * (N + 1) +    popleft = que.popleft +    append = que.append -        d, prev = heappop(que) -        if dist[prev] < d: -            continue -        for next in graph[prev]: -            d1 = d + 1 -            if dist[next] > d1: -                dist[next] = d1 -                heappush(que, (d1, next)) -    return dist +        x = popleft() +        d = dist[x] +        for next in graph[x]: +            if dir[next] != None: +                continue +            dir[next] = str(x) +            append(next) +    return dir -dist = dijkstra(1) -if INF in dist[1:]: -    print("No") -    exit() -answer = [None] * (N + 1) -for i in range(2, N + 1): -    a = INF -    for c in graph[i]: -        if dist[c] < a: -            a = dist[c] -            answer[i] = str(c) +dir = bfs(1) -print(("\n".join(answer[2:]))) +print(("\n".join(dir[2:])))