Scanf.scanf "%d %d" (fun n m ->
    let par = Array.init n (fun i -> i) in
    let count = Array.make n 1 in
    let ab = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun a b -> a - 1, b - 1)) in

    let rec root x =
        if x = par.(x) then x else
            let r = root par.(x) in
            let () = par.(x) <- r in
            r
    in

    let merge a b =
        if root a <> root b then (
            count.(par.(a)) <- count.(par.(a)) + count.(par.(b));
            par.(par.(b)) <- par.(a);
        )
    in
    let inc = Array.make m 0 in

    let rec loop i cur =
        if i < 0 then inc else (
            inc.(i) <- cur;
            let a, b = ab.(i) in
            if root a <> root b then (
                let ca = count.(par.(a)) in
                let cb = count.(par.(b)) in
                merge a b;
                loop (i - 1) (cur - ca * cb)
            ) else loop (i - 1) cur
        )
    in
    Array.iter (Printf.printf "%d\n") @@ loop (m - 1) (n * (n - 1) / 2)
)