open Batteries
open Printf

let ($) g f x = g (f x)

module MyList = struct
  include List
  let foldl = fold_left
  let foldli = fold_lefti
  let foldr = fold_right
  let foldri = fold_righti
  
  let flatmap = concat_map

  let zipf = map2
  let zipfi = map2i
end

module L = MyList

let swap = Tuple2.swap

let atoi = int_of_string
let itoa = string_of_int
let atof = float_of_string
let ftoa = string_of_float
let ctoi = int_of_char
let itoc = char_of_int

let stocl = String.to_list
let cltos = String.of_list
let spsp s = String.split_on_char ' ' s

module MyString = struct
  include String

  let map' f s = L.map f (stocl s)
  let mapi' f s = L.map f (stocl s)

  let zipf f a b = L.zipf f (stocl a) (stocl b)
  let zipfi f a b = L.zipfi f (stocl a) (stocl b)

  let mkstr f sep ls =
    L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)
end

module S = MyString

module MySet (Ord : Set.OrderedType) = struct
  include Set.Make(Ord)

  let fold' f s z = fold f z s
end

module St = MySet

module MyMap (Ord : Map.OrderedType) = struct
  include Map.Make(Ord)

  let apply = find
  let apply_or = find_default
end

module Mp = MyMap


let rds () = read_line ()

let rdi () = atoi @@ rds ()

let rdhs () = spsp @@ rds ()
let rdhi () = rdhs () |> L.map atoi

let rdi2 () = match rdhi () with
  | a::b::_ -> (a, b)
  | _ -> (0, 0)

let rdi3 () = match rdhi () with
| a::b::c::_ -> (a, b, c)
| _ -> (0, 0, 0)

let rdi4 () = match rdhi () with
| a::b::c::d::_ -> (a, b, c, d)
| _ -> (0, 0, 0, 0)

let rdv n rdf =
  let rec rdv' n =
    if n <= 0 then []
    else (
      let s = rdf () in
      s::(rdv' (n - 1))
    )
  in rdv' n

let rdvi n = rdv n rdi
let rdvi2 n = rdv n rdi2
let rdvi3 n = rdv n rdi3
let rdvi4 n = rdv n rdi4

let puts s = print_endline s
let putyn b = puts (if b then "Yes" else "No")
let puti i = puts @@ itoa i

let set_power ls =
  let rec set_power' ls pls =
    match ls with
    | [] -> pls
    | hd::tl -> set_power' tl (L.flatmap (fun p -> [p; hd::p]) pls)
  in set_power' ls [[]]


let rdhf () = rdhs () |> L.map atof
let rdf4 () = match rdhf () with
| a::b::c::d::_ -> (a, b, c, d)
| _ -> (0., 0., 0., 0.)


module Graph = struct
  module Vs = St(Int)
  module Vm = Mp(Int)

  type 'a t = { nb : Vs.t Vm.t; vdt : 'a Vm.t }

  let nothing = { nb = Vm.empty; vdt = Vm.empty }

  let add_edge (e : int * int) g =
    let (v1, v2) = e in
    let nbvs = g.nb |> Vm.apply_or Vs.empty v1 in
    let nb1 = g.nb |> Vm.add v1 (nbvs |> Vs.add v2) in
    { g with nb = nb1 }

  let add_uedge e g =
    add_edge e (add_edge (swap e) g)

  let from_edges es =
    es |> L.foldl (fun g e -> add_edge e g) nothing

  let from_uedges es =
    es |> L.foldl (fun g e -> add_uedge e g) nothing


end

module G = Graph
module Vs = G.Vs
module Vm = G.Vm

let _ =
  let (n, m) = rdi2 () in
  let es = rdv m rdi2 in
  let graph = G.from_uedges es in

  let expand v vp =
    let nb = (graph.nb |> Vm.apply v) in
    nb |> Vs.fold' (fun nbv (nfr, cvp) ->
      if Vm.mem nbv cvp then
        (nfr, cvp)
      else
        (nfr |> Vs.add nbv,
          cvp |> Vm.add nbv v)
    ) (Vs.empty, vp) in
  
  let rec march fr vp =
    if Vs.is_empty fr then
      vp
    else
      let (nfr, nvp) =
        fr |> Vs.fold' (fun v (nfr, cvp) ->
          let (nfr1, nvp) = expand v cvp in
          (Vs.union nfr nfr1, nvp)
        ) (Vs.empty, vp)
      in
      march nfr nvp 
  in

  let rvp = march (Vs.singleton 1) (Vm.singleton 1 0) in
  let result = L.tl @@ Vm.bindings rvp in

  puts "Yes";
  result |> L.iter (fun (v, p)-> puti p)
;;


Measured memory_bytes: 63144