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