(* O(m α(n)) *)
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ab_s = Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a - 1, b - 1
let ab_s = Array.init m (fun i -> ab_s.(m - 1 - i))
let ps = Array.make n @@ -1
let rec find x =
  if ps.(x) < 0 then x
  else let y = find ps.(x) in ps.(x) <- y; y
let unite x y =
  let x = find x in
  let y = find y in
  if x = y then false
  else
    (if ps.(x) < ps.(y) then (ps.(x) <- ps.(x) + ps.(y); ps.(y) <- x)
    else (ps.(y) <- ps.(y) + ps.(x); ps.(x) <- y);
    true)
let size x = -ps.(find x)
let _ =
  let f acc (a, b) =
    let x, y = size a, size b in
    (List.hd acc - if unite a b then x * y else 0) :: acc in
  Array.sub ab_s 0 @@ m - 1 |> Array.fold_left f [n * (n - 1) / 2] |> List.iter @@ fun v -> Printf.printf "%d\n" v