(* 素集合データ構造 *)
module UnionFind : sig
  type t

  (* 1要素だけを含む集合を作る *)
  val make : unit -> t
  (* 与えられた集合同士が同一かどうか判定する *)
  val equal : t -> t -> bool
  (* 与えられた集合同士を合併する *)
  val unite : t -> t -> unit
  (* 与えられた集合に属する要素の数を求める *)
  val cardinal : t -> int
end = struct
  (* type t = node ref
     and node = Either int t
     みたいなのがやりたくて，OCamlの実行時表現はintとそれ以外を区別できるので
     省メモリのためにこうしている *)
  type t = Obj.t ref

  let make () = ref (Obj.repr 1)

  let rec find uf =
    if Obj.is_int !uf
    then uf
    else begin
      let root = find (Obj.magic !uf) in
      uf := Obj.repr root; root
    end

  let equal uf uf' = find uf == find uf'

  let unite uf uf' =
    let root = find uf in
    let root' = find uf' in
    if root != root' then begin
      let card : int = Obj.magic !root in
      let card' : int = Obj.magic !root' in
      let root, root' =
        if card <= card'
        then root, root'
        else root', root in
      root := Obj.repr (card + card');
      root' := Obj.repr root
    end

  let cardinal uf = Obj.magic @@ ( ! ) @@ find uf
end

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let abs = Array.init m @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun a b -> a - 1, b - 1 in
  let uf = Array.init n @@ fun _ -> UnionFind.make () in
  let ans = Array.make (m + 1) (n * (n - 1) / 2) in
  for i = m - 1 downto 0 do
    let (a, b) = abs.(i) in
    ans.(i) <- ans.(i + 1) -
      if UnionFind.equal uf.(a) uf.(b)
      then 0
      else begin
        let n = UnionFind.cardinal uf.(a) in
        let m = UnionFind.cardinal uf.(b) in
        UnionFind.unite uf.(a) uf.(b); n * m
      end
  done;
  for i = 1 to m do
    Printf.printf "%d\n" ans.(i)
  done

