open Printf
open Scanf

class unionfind size =
  object(self)
  val mutable forest = [|(0,0)|]
  initializer begin
    forest <- Array.init size (fun x -> (x,1))
  end
  method forest () = begin
    forest
  end
  method print_forest () = begin
    let _ = Array.iter (fun x -> Printf.printf "(%d,%d);" (fst x) (snd x)) forest in
    print_newline()
  end
  method find i = begin
      let (index, size) = forest.(i) in
      if (i = index) then (i, size)
      else
       let (nxt_index, nxt_size) = self#find index in
       forest.(i) <- (nxt_index, nxt_size);
       (nxt_index, nxt_size)
  end

  method union i j = begin
    let (x, x_size) = self#find i in
    let (y, y_size) = self#find j in

    if (x = y) then ()
    else
      let () = forest.(x) <- (y, x_size + y_size) in
      forest.(y) <- (y, x_size + y_size)
  end
end

let (n,m) = sscanf (read_line ()) " %d %d" (fun a b -> (a,b))
let query = Array.make m (0,0);;
for i = 0 to m-1 do
    query.(i) <- sscanf (read_line ()) " %d %d" (fun a b-> (a-1,b-1))
done

let ans = Array.make m 0;;
ans.(m-1) <- n*(n-1)/2;;
let forest = new unionfind n;;

for i = m-2 downto 0 do
  (*let _ = forest#print_forest() in*)
  let a,b = query.(i+1) in
  let ain,asi = forest#find a in
  let bin,bsi = forest#find b in
  if (ain = bin) then
    ans.(i) <- ans.(i+1)
  else
    let () = ans.(i) <- ans.(i+1) - (asi * bsi) in
    forest#union ain bin
done;;

for i = 0 to m-1 do
  printf ("%d\n") ans.(i)
done
