///////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <typeinfo>
#include <sys/time.h>

using namespace std;

///////////////////////////////////////////////////////////////////////////////

#define pb push_back

map<int, int> uf_parent;
map<int, int> uf_count;
map<int, int> uf_rank;

void uf_init(int n)
{
        for (int i = 0; i < n; ++i) {
                uf_parent[i] = i;
                uf_count[i] = 1;
                uf_rank[i] = 0;
        }
}

int uf_root(int i)
{
        if (uf_parent[i] == i) return i;
        uf_parent[i] = uf_root(uf_parent[i]);
        return uf_parent[i];
}

void uf_unite(int i, int j)
{
        int rooti = uf_root(i);
        int rootj = uf_root(j);

        if (rooti == rootj) return;

        if (uf_rank[rootj] < uf_rank[rooti]) {
                uf_parent[i] = uf_parent[j] = uf_parent[rootj] = rooti;
                uf_count[rooti] += uf_count[rootj];
        }
        else {
                uf_parent[i] = uf_parent[j] = uf_parent[rooti] = rootj;
                uf_count[rootj] += uf_count[rooti];
                if (uf_rank[rootj] == uf_rank[rooti]) uf_rank[rootj]++;
        }
}

bool uf_same(int i, int j)
{
        return uf_root(i) == uf_root(j);
}

struct T2 {
        long t0;
        long t1;
};

struct T3 {
        long t0;
        long t1;
        long t2;
};

struct T4 {
        long t0;
        long t1;
        long t2;
        long t3;
};

bool operator<(const T2 &lhs, const T2 &rhs)
{
        if (lhs.t0 != rhs.t0) return lhs.t0 < rhs.t0;
        return lhs.t1 < rhs.t1;
}

bool operator>(const T2 &lhs, const T2 &rhs)
{
        if (lhs.t0 != rhs.t0) return lhs.t0 > rhs.t0;
        return lhs.t1 > rhs.t1;
}

bool operator==(const T2 &lhs, const T2 &rhs)
{
        if (lhs.t0 != rhs.t0) return false;
        return lhs.t1 == rhs.t1;
}

bool operator!=(const T2 &lhs, const T2 &rhs)
{
        return !(lhs == rhs);
}

bool operator<(const T3 &lhs, const T3 &rhs)
{
        if (lhs.t0 != rhs.t0) return lhs.t0 < rhs.t0;
        if (lhs.t1 != rhs.t1) return lhs.t1 < rhs.t1;
        return lhs.t2 < rhs.t2;
}

bool operator>(const T3 &lhs, const T3 &rhs)
{
        if (lhs.t0 != rhs.t0) return lhs.t0 > rhs.t0;
        if (lhs.t1 != rhs.t1) return lhs.t1 > rhs.t1;
        return lhs.t2 > rhs.t2;
}

bool operator==(const T3 &lhs, const T3 &rhs)
{
        if (lhs.t0 != rhs.t0) return false;
        if (lhs.t1 != rhs.t1) return false;
        return lhs.t2 == rhs.t2;
}

bool operator!=(const T3 &lhs, const T3 &rhs)
{
        return !(lhs == rhs);
}

bool operator<(const T4 &lhs, const T4 &rhs)
{
        if (lhs.t0 != rhs.t0) return lhs.t0 < rhs.t0;
        if (lhs.t1 != rhs.t1) return lhs.t1 < rhs.t1;
        if (lhs.t2 != rhs.t2) return lhs.t2 < rhs.t2;
        return lhs.t3 < rhs.t3;
}

bool operator>(const T4 &lhs, const T4 &rhs)
{
        if (lhs.t0 != rhs.t0) return lhs.t0 > rhs.t0;
        if (lhs.t1 != rhs.t1) return lhs.t1 > rhs.t1;
        if (lhs.t2 != rhs.t2) return lhs.t2 > rhs.t2;
        return lhs.t3 > rhs.t3;
}

bool operator==(const T4 &lhs, const T4 &rhs)
{
        if (lhs.t0 != rhs.t0) return false;
        if (lhs.t1 != rhs.t1) return false;
        if (lhs.t2 != rhs.t2) return false;
        return lhs.t3 == rhs.t3;
}

bool operator!=(const T4 &lhs, const T4 &rhs)
{
        return !(lhs == rhs);
}

void longin(long &a)
{
        cin >> a;
}

void longinl1(auto &v, long count)
{
        for (long i = 0; i < count ; ++i) {
                long a;
                cin >> a;
                v.push_back(a);
        }
}

void longinl2(auto &v, long count)
{
        for (long i = 0; i < count ; ++i) {
                long a, b;
                cin >> a >> b;
                v.push_back({a, b});
        }
}

void longinl3(auto &v, long count)
{
        for (long i = 0; i < count ; ++i) {
                long a, b, c;
                cin >> a >> b >> c;
                v.push_back({a, b, c});
        }
}

void longina(auto &v, long count)
{
        longinl1(v, count);
}

long min(const vector<long> v)
{
        long ret = (long)numeric_limits<double>::infinity();
        for (auto i : v) ret = min(ret, i);
        return ret;
}

void sort(vector<long> &v)
{
        sort(v.begin(), v.end());
}

void sort_reverse(vector<long> &v)
{
        sort(v.begin(), v.end(), greater<long>());
}

void get_divisors(vector<long> &retlist, long x)
{
        for (int i = 1; i < sqrt(x) + 3; ++i) {
                if (x % i == 0) {
                        retlist.push_back(i);
                        retlist.push_back(x / i);
                }
        }
}

void intersection(const set<long> &a, const set<long> &b,
                  set<long> &result)
{
        vector<long> resultlist;

        set_intersection(a.begin(), a.end(),
                         b.begin(), b.end(),
                         back_inserter(resultlist));

        set<long> resultset(resultlist.begin(), resultlist.end());
        result = resultset;
}

long combination(long x, long y)
{
        if (y > x / 2L) y = x - y;

        long ret = 1;
        for (int i = 0; i < y; ++i) {
                ret *= x--;
                ret /= (i + 1);
        }

        return ret;
}

///////////////////////////////////////////////////////////////////////////////

int main()
{
        long n, m;
        longin(n); longin(m);

        vector<T2> ablist;
        longinl2(ablist, m);

        uf_init(n);

        vector<long> anslist;
        long now = combination(n, 2);
        anslist.pb(now);
        int a;
        int b;
        int root_a;
        int root_b;

        for (int i = m - 1; i >= 0; --i) {
                a = ablist[i].t0;
                b = ablist[i].t1;

                root_a = uf_root(a);
                root_b = uf_root(b);

                if (root_a != root_b) {
                        now -= uf_count[root_a] * uf_count[root_b];
                        uf_unite(a, b);
                }

                anslist.pb(now);
        }

        reverse(anslist.begin(), anslist.end());
        for (int i = 1; i < anslist.size(); ++i)
                cout << anslist[i] << endl;

        return 0;
}

///////////////////////////////////////////////////////////////////////////////


Measured memory_bytes: 20848