module UnionFind : sig
  type t
  val make : int -> t
  val find : t -> int -> int
  val size : t -> int -> int
  val unite : t -> int -> int -> unit
  val is_same : t -> int -> int -> bool
end = struct
  type t = { rank: int array; parent: int array; size: int array }

  let make n = 
    { rank = Array.make n 0; 
      parent = Array.init n (fun i -> i);
      size = Array.make n 1 }

  let rec find uf i = 
    if uf.parent.(i) = i then i
    else begin
      let j = find uf uf.parent.(i) in 
      uf.parent.(i) <- j; j
    end
  
  let size uf i = uf.size.(find uf i)

  let unite uf i j =
    let x = find uf i in
    let y = find uf j in
    if x = y then ()
    else if uf.rank.(x) < uf.rank.(y) then begin
      uf.parent.(x) <- y;
      uf.size.(y) <- uf.size.(y) + uf.size.(x)
    end
    else begin
      uf.parent.(y) <- x;
      uf.size.(x) <- uf.size.(x) + uf.size.(y);
      if uf.rank.(x) = uf.rank.(y) then uf.rank.(x) <- uf.rank.(y) + 1
    end

  let is_same uf i j = find uf i = find uf j
end

let (n, m) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n m -> (n, m)
let ab = Array.init m @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun a b -> (a - 1, b - 1)

let () =
  let ans = Array.make (m + 1) 0 in
  let uf = UnionFind.make n in
  ans.(m) <- (n * (n - 1)) / 2;
  for i = m - 1 downto 0 do
    let (a, b) = ab.(i) in
    if UnionFind.is_same uf a b then
      ans.(i) <- ans.(i + 1)
    else begin
      ans.(i) <- ans.(i + 1) - (UnionFind.size uf a) * (UnionFind.size uf b);
      UnionFind.unite uf a b;
    end
  done;
  for i = 1 to m do
    Printf.printf "%d\n" ans.(i)
  done