#light "off"

open System
open System.Linq
open System.Collections.Generic

let INF64 = 100000000000L

let readInt () =
    let s = stdin.ReadLine() in
    int s

let readInt64 () =
    let s = stdin.ReadLine() in
    int64 s

let readIntArray () =
    stdin.ReadLine().Split(' ') |>
    Array.map int

(*
let readIntList () =
    stdin.ReadLine().Split(' ') |>
    Array.map int |>
    Array.toList
*)
(*
let readIntList () =
    stdin.ReadToEnd()
        .Split('\n')
        .Select(fun s -> s.Replace("\r", ""))
        .Where(fun s -> s.Length > 0)
        .Select(fun e -> int e)
        .ToArray() |>
    Array.toList
*)

type Edge = {NodeA: int; NodeB: int}

let parseProblem () =
    let ar = readIntArray () in
    let N, M = ar.[0], ar.[1] in
    let bridges = Array.create M {NodeA = 0; NodeB = 0} in
    for i in 0 .. M - 1 do
        let ar2 = readIntArray () in
        bridges.[i] <- {NodeA = ar2.[0] - 1; NodeB = ar2.[1] - 1}
    done;
    N, M, bridges

let createParents N =
    Array.create N -1

let rec findRoot (p: int []) (a: int) =
    let x = p.[a] in
    if x >= 0 then
        findRoot p x
    else
        a

let findThenUnion p a b =
    let x = findRoot p a in
    let y = findRoot p b in
    let same = x = y in
    let size_a, size_b = -p.[x], -p.[y] in
    begin
        if not same then
            let xx, yy = if size_a >= size_b then x, y else x, y in
            p.[xx] <- p.[xx] + p.[yy];
            p.[yy] <- xx;
    end;
    same, (int64)size_a, (int64)size_b

[<EntryPoint>]
let main argv =
    let N, M, bridges = parseProblem () in
    let parents = createParents N in
    let ans = Array.create M -1L in
    for i = M downto 1 do
        if i = M then
            ans.[i - 1] <- (int64)N * ((int64)N - 1L) / 2L
        else
            let a, b = bridges.[i].NodeA, bridges.[i].NodeB in
            let same, size_a, size_b = findThenUnion parents a b in
            if same then
                ans.[i - 1] <- ans.[i]
            else
                ans.[i - 1] <- ans.[i] - size_a * size_b;
    done;
    for i in 0 .. M - 1 do
        printfn "%d" <| ans.[i]
    done;
    0