open System
open System.Collections.Generic

let n, m =
    let l = Console.ReadLine().Split(' ') |> Array.map int
    l.[0], l.[1]

let connCondition: Map<int, ResizeArray<int>> =
    let concond =
        Map(
            seq {
                for i in 0 .. n - 1 do
                    (i, new ResizeArray<int>())
            })

    for i in 1 .. m do
        let a, b =
            let l = Console.ReadLine().Split(' ') |> Array.map int
            l.[0] - 1, l.[1] - 1
        concond.[a].Add(b)
        concond.[b].Add(a)

    concond

let path = Array.init n (fun i -> if i = 0 then 0 else -1)

let q = Queue<int>()
q.Enqueue(0)
let mutable cnt = 0

while q.Count <> 0 do
    let i = q.Dequeue()

    for j in connCondition.[i] do
        if path.[j] = -1 then
            cnt <- cnt + 1
            q.Enqueue(j)
            path.[j] <- i
        else
            ()

if cnt = n - 1 then
    Console.WriteLine "Yes"

    for i in 1 .. n - 1 do
        Console.WriteLine (path.[i] + 1)
else
    Console.WriteLine "No"