let rec find x uf =
  if uf.(x) < 0 then x else 
  let x' = find uf.(x) uf in
  uf.(x) <- x'; x'
let unite x y uf =
  let x, y = find x uf,find y uf in
  if x <> y then
    if uf.(x) < uf.(y) then ((
      uf.(x) <- uf.(x) + uf.(y);
      uf.(y) <- x
    )) else ((
      uf.(y) <- uf.(x) + uf.(y);
      uf.(x) <- y
    ))
let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let es = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun x y -> x-1, y-1)) in
  let uf = Array.make n (-1) in
  Array.fold_right (fun (x, y) (v, stk) -> 
    let x, y = find x uf, find y uf in
    if x = y then (v, v::stk)
    else ((
      let xc, yc = uf.(x), uf.(y) in
      unite x y uf;
      (v - xc * yc, v::stk)
    ))) es (n*(n-1)/2, [])
  |> snd |> List.iter (Printf.printf "%d\n")
    
