from collections import deque

import sys

input = sys.stdin.readline





def bfs(NEAR, S, N):  # 幅優先探索  # キュー

    pas = [-1 for _ in range(N)]

    pas[S] = 's'

    frag = set([S])

    que = deque([S])



    while len(que) > 0:

        q = que.popleft()

        for i in NEAR[q]:

            if i in frag:  # 処理済みか否か

                continue

            pas[i]=q

            que.append(i)

            frag.add(i)

    return pas





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

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



near = [[] for _ in range(n)]

for a, b in ab:

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

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

pas = bfs(near, 0, n)



if all(pas[i] != -1 for i in range(n)):

    print('Yes')

    for i in range(1, n):

        print((pas[i] + 1))

else:

    print('No')

from collections import deque





def nearlist(N, LIST):

    NEAR = [set() for _ in range(N)]

    for a, b in LIST:

        NEAR[a - 1].add(b - 1)

        NEAR[b - 1].add(a - 1)

    return NEAR





def bfs(NEAR, S, N):  # 幅優先探索  # キュー

    PATH = [-1 for _ in range(N)]

    PATH[S] = 's'

    frag, que = set([S]), deque([S])



    while len(que) > 0:

        q = que.popleft()

        for i in NEAR[q]:

            if i in frag:

                continue

            PATH[i] = q

            que.append(i), frag.add(i)

    return PATH





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

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



near = nearlist(n, ab)

path = bfs(near, 0, n)



print('Yes')

for i in range(1, n):

    print((path[i] + 1))

from collections import deque
import sys

input = sys.stdin.readline


def bfs(NEAR, S, N):  # 幅優先探索  # キュー
    pas = [-1 for _ in range(N)]
    pas[S] = "s"
    frag = set([S])
    que = deque([S])
    while len(que) > 0:
        q = que.popleft()
        for i in NEAR[q]:
            if i in frag:  # 処理済みか否か
                continue
            pas[i] = q
            que.append(i)
            frag.add(i)
    return pas


n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
near = [[] for _ in range(n)]
for a, b in ab:
    near[a - 1].append(b - 1)
    near[b - 1].append(a - 1)
pas = bfs(near, 0, n)
if all(pas[i] != -1 for i in range(n)):
    print("Yes")
    for i in range(1, n):
        print((pas[i] + 1))
else:
    print("No")

from collections import deque


def nearlist(N, LIST):
    NEAR = [set() for _ in range(N)]
    for a, b in LIST:
        NEAR[a - 1].add(b - 1)
        NEAR[b - 1].add(a - 1)
    return NEAR


def bfs(NEAR, S, N):  # 幅優先探索  # キュー
    PATH = [-1 for _ in range(N)]
    PATH[S] = "s"
    frag, que = set([S]), deque([S])
    while len(que) > 0:
        q = que.popleft()
        for i in NEAR[q]:
            if i in frag:
                continue
            PATH[i] = q
            que.append(i), frag.add(i)
    return PATH


n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
near = nearlist(n, ab)
path = bfs(near, 0, n)
print("Yes")
for i in range(1, n):
    print((path[i] + 1))

-import sys -input = sys.stdin.readline + +def nearlist(N, LIST): +    NEAR = [set() for _ in range(N)] +    for a, b in LIST: +        NEAR[a - 1].add(b - 1) +        NEAR[b - 1].add(a - 1) +    return NEAR -    pas = [-1 for _ in range(N)] -    pas[S] = "s" -    frag = set([S]) -    que = deque([S]) +    PATH = [-1 for _ in range(N)] +    PATH[S] = "s" +    frag, que = set([S]), deque([S]) -            if i in frag:  # 処理済みか否か +            if i in frag: -            pas[i] = q -            que.append(i) -            frag.add(i) -    return pas +            PATH[i] = q +            que.append(i), frag.add(i) +    return PATH -near = [[] for _ in range(n)] -for a, b in ab: -    near[a - 1].append(b - 1) -    near[b - 1].append(a - 1) -pas = bfs(near, 0, n) -if all(pas[i] != -1 for i in range(n)): -    print("Yes") -    for i in range(1, n): -        print((pas[i] + 1)) -else: -    print("No") +near = nearlist(n, ab) +path = bfs(near, 0, n) +print("Yes") +for i in range(1, n): +    print((path[i] + 1))