Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.IO

Public Class Program


    Public Shared Sub Main(args As String())

        Dim input1() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split, AddressOf Integer.Parse)
        Dim N As Integer = input1(0)
        Dim M As Integer = input1(1)

        Dim nodes(N + 1) As List(Of Integer)
        For i As Integer = 0 To N
            nodes(i) = New List(Of Integer)
        Next



        For i As Integer = 1 To M
            Dim inputnode() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split, AddressOf Integer.Parse)
            nodes(inputnode(0)).Add(inputnode(1))
            nodes(inputnode(1)).Add(inputnode(0))
        Next

        Dim Queue As New Queue(Of Integer)
        Dim depths = Enumerable.Repeat(-1, N + 1).ToArray()
        Dim michishirube(N + 1) As Integer
        Dim working As Integer = 1
        Queue.Enqueue(1)

        Do While Queue.Count > 0

            working = Queue.Dequeue()


            For Each NN In nodes(working)

                If Not depths(NN) = -1 Then
                    depths(NN) = depths(working) + 1
                    Queue.Enqueue(NN)
                    michishirube(NN) = working
                End If

            Next

        Loop

        Console.WriteLine("Yes")

        For i As Integer = 2 To N
            Console.WriteLine(michishirube(i))
        Next



    End Sub




End Class