# -*- coding: utf-8 -*-

"""

@author: H_Hoshigi

"""



import queue



def main():

    N, M = list(map(int, input().split()))



    connedted_room_list = [ [] for i in range(N)] # ここでNとMを書き間違えていた。

    for i in range(M):

        A, B = list(map(int, input().split()))

        connedted_room_list[A-1].append(B-1)

        connedted_room_list[B-1].append(A-1)



    answer_list = [ -1 for i in range(N)]

    answer_list[0] = 0



    next_rooms_queue = queue.Queue()

    next_rooms_queue.put(0)

    now_room = int()

    while not next_rooms_queue.empty():

        now_room = next_rooms_queue.get()

        for i in connedted_room_list[now_room]:

            if answer_list[i] == -1:

                answer_list[i] = now_room

                next_rooms_queue.put(i)



    

    is_escapable = True

    for i in range(1, N):

        if answer_list[i] == -1:

            is_escapable = False

            break



    if is_escapable:

        print("Yes")

        for i in range(1, N):

            print((answer_list[i]+1))

    else:

        print("No")



if __name__ == "__main__":

    main()





# -*- coding: utf-8 -*-

"""

@author: H_Hoshigi

"""



import queue



def main():

    N, M = list(map(int, input().split()))



    connedted_room_list = [ [] for i in range(N)] # ここでNとMを書き間違えていた。

    for i in range(M):

        A, B = list(map(int, input().split()))

        connedted_room_list[A-1].append(B-1)

        connedted_room_list[B-1].append(A-1)



    answer_list = [ -1 for i in range(N)]

    answer_list[0] = 0



    next_rooms_queue = queue.Queue()

    next_rooms_queue.put(0)

    now_room = int()

    while not next_rooms_queue.empty():

        now_room = next_rooms_queue.get()

        for i in connedted_room_list[now_room]:

            if answer_list[i] == -1:

                answer_list[i] = now_room

                next_rooms_queue.put(i)



    

    is_escapable = True

    '''

    for i in range(1, N):

        if answer_list[i] == -1:

            is_escapable = False

            break

    '''



    if is_escapable:

        print("Yes")

        for i in range(1, N):

            print((answer_list[i]+1))

    else:

        print("No")



if __name__ == "__main__":

    main()





# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
import queue


def main():
    N, M = list(map(int, input().split()))
    connedted_room_list = [[] for i in range(N)]  # ここでNとMを書き間違えていた。
    for i in range(M):
        A, B = list(map(int, input().split()))
        connedted_room_list[A - 1].append(B - 1)
        connedted_room_list[B - 1].append(A - 1)
    answer_list = [-1 for i in range(N)]
    answer_list[0] = 0
    next_rooms_queue = queue.Queue()
    next_rooms_queue.put(0)
    now_room = int()
    while not next_rooms_queue.empty():
        now_room = next_rooms_queue.get()
        for i in connedted_room_list[now_room]:
            if answer_list[i] == -1:
                answer_list[i] = now_room
                next_rooms_queue.put(i)
    is_escapable = True
    for i in range(1, N):
        if answer_list[i] == -1:
            is_escapable = False
            break
    if is_escapable:
        print("Yes")
        for i in range(1, N):
            print((answer_list[i] + 1))
    else:
        print("No")


if __name__ == "__main__":
    main()

# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
import queue


def main():
    N, M = list(map(int, input().split()))
    connedted_room_list = [[] for i in range(N)]  # ここでNとMを書き間違えていた。
    for i in range(M):
        A, B = list(map(int, input().split()))
        connedted_room_list[A - 1].append(B - 1)
        connedted_room_list[B - 1].append(A - 1)
    answer_list = [-1 for i in range(N)]
    answer_list[0] = 0
    next_rooms_queue = queue.Queue()
    next_rooms_queue.put(0)
    now_room = int()
    while not next_rooms_queue.empty():
        now_room = next_rooms_queue.get()
        for i in connedted_room_list[now_room]:
            if answer_list[i] == -1:
                answer_list[i] = now_room
                next_rooms_queue.put(i)
    is_escapable = True
    """
    for i in range(1, N):
        if answer_list[i] == -1:
            is_escapable = False
            break
    """
    if is_escapable:
        print("Yes")
        for i in range(1, N):
            print((answer_list[i] + 1))
    else:
        print("No")


if __name__ == "__main__":
    main()

+    """ +    """