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

#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<long, long> uf_parent;
map<long, long> uf_count;
map<long, long> uf_rank;

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

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

void uf_unite(long i, long j)
{
        long rooti = uf_root(i);
        long 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(long i, long 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);
        long a;
        long b;
        long root_a;
        long 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: 23536