#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 prev = Array.create (n + 1) (-1)

let mutable q = [ 1 ]

let rec loop (q : int list) =
    let mutable q2 = []
    for v in q do
        for t in graph.[v] do
            if prev.[t] = -1 then
                prev.[t] <- v
                q2 <- t :: q2
        
    if not q2.IsEmpty then
        loop q2

loop [ 1 ]

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