import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Edge = Tuple!(int, "u", int, "v");

void main() {
    int n, m;
    scan(n, m);

    auto es = new Edge[](m);
    foreach (i ; 0 .. m) {
        int ui, vi;
        scan(ui, vi);
        es[i] = Edge(ui - 1, vi - 1);
    }

    auto ans = new long[](m + 1);
    ans[m] = 1L * n * (n - 1) / 2;

    auto uf = UnionFind(n);

    foreach_reverse (i ; 0 .. m) {
        int u = es[i].u;
        int v = es[i].v;

        if (uf.same(u, v)) {
            ans[i] = ans[i + 1];
        }
        else {
            debug {
                writefln("cnt[u]: %d, cnt[v]: %d", uf.count(u), uf.count(v));
            }
            long d = 1L * uf.count(u) * uf.count(v);
            ans[i] = ans[i + 1] - d;
            uf.merge(u, v);
        }
    }

    writefln("%(%s\n%)", ans[1 .. $]);
}


struct UnionFind {
    private {
        int _size;
        int[] _parent;
        long[] cnt;
    }

    this(int N) 
    in {
        assert(N > 0);
    }
    body {
        _size = N;
        _parent = new int[](_size);
        cnt = new long[](_size);
        foreach (i ; 0 .. _size) {
            _parent[i] = i;
            cnt[i] = 1;
        }
    }

    int findRoot(int x)
    in {
        assert(0 <= x && x < _size);
    }
    body {
        if (_parent[x] != x) {
            _parent[x] = findRoot(_parent[x]);
        }

        return _parent[x];
    }

    bool same(int x, int y)
    in {
        assert(0 <= x && x < _size);
        assert(0 <= y && y < _size);
    }
    body {
        return findRoot(x) == findRoot(y);
    }

    void merge(int x, int y)
    in {
        assert(0 <= x && x < _size);
        assert(0 <= y && y < _size);
    }
    body {
        int u = findRoot(x);
        int v = findRoot(y);

        if (u == v) return;

        _parent[v] = u;
        cnt[u] += cnt[v];
        cnt[v] = 0;
    }

    long count(int x) {
        return cnt[findRoot(x)];
    }
}




int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

//alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {writeln(b ? "Yes" : "No");}
void YES(bool b) {writeln(b ? "YES" : "NO");}
T[] readArr(T)() {return readln.split.to!(T[]);}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 6268