#nowarn "25"

open System

let INF = int64 1e18

let [|n; m|] = stdin.ReadLine().Split() |> Array.map(int)

let mutable graph = Array.create (int n + 1) []
for i in 1 .. m do
    let [|a; b|] = stdin.ReadLine().Split() |> Array.map(int)
    graph.[a] <- b :: graph.[a]
    graph.[b] <- a :: graph.[b]

let d = Array.create (n + 1) INF
let prev = Array.create (n + 1) (-1)

d.[1] <- 0L

let mutable q = Set<int64 * int> [ (0L, 1) ]

let rec loop () =
    if not q.IsEmpty then
        let (c, v) = q.MinimumElement
        q <- q.Remove (c, v)

        for t in graph.[v] do
            let c2 = d.[v] + 1L
            if d.[t] > c2 then
                d.[t] <- c2
                prev.[t] <- v
                q <- q.Add (d.[t], t)
        
        loop ()
loop ()

printfn "Yes"
for i in 2 .. n do
    printfn "%d" prev.[i]