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 ans = Array.make n 0

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 () =
  let que = Queue.create () in
  List.iter (fun i ->
    ans.(i) <- 1;
    Queue.add i que
  ) @@ Hashtbl.find_all tbl 0;
  while not (Queue.is_empty que) do
    let t = Queue.pop que in
    List.iter (fun i ->
      if ans.(i) = 0 then begin
        ans.(i) <- t + 1;
        Queue.add i que
      end
    ) @@ Hashtbl.find_all tbl t
  done;
  print_endline "Yes";
  for i = 1 to (n - 1) do
    Printf.printf "%d\n" ans.(i)
  done