let tap f x = f x; x
let (n, m) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n m -> (n, m)
let ab = Array.init m @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun a b -> (a - 1, b - 1)

let d = Array.make n max_int

let tbl = tap
  (fun tbl -> Array.iter (fun (a, b) -> Hashtbl.add tbl a b; Hashtbl.add tbl b a) ab)
  (Hashtbl.create n)

let rec loop i cost =
  d.(i) <- cost;
  List.iter (fun n ->
    if d.(n) > cost + 1 then loop n (cost + 1)
  ) @@ Hashtbl.find_all tbl i


let () =
  loop 0 0;
  print_endline "Yes";
  for i = 1 to (n - 1) do
    Printf.printf "%d\n" @@ (List.find (fun n -> d.(n) = d.(i) - 1) @@ Hashtbl.find_all tbl i) + 1
  done