/*input
6 5
2 3
1 2
5 6
3 4
4 5
*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb                push_back
#define pp                pop_back
#define nl                cout << "\n"
#define MIN(con)          (*min_element(ALL(con)))
#define MAX(con)          (*max_element(ALL(con)))
#define NX(cont)          next_permutation(ALL(cont))
#define PX(cont)          prev_permutation(ALL(cont))
#define prec(n)           cout << fixed << setprecision(n)
#define PI                3.14159265358979323846264338327951
#define all(c)            c.begin(),c.end()
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define sp                cout << " "
#define mod               1000000007    //9
#define ifalse            ios_base::sync_with_stdio(false),cin.tie(NULL)

using ll = long long;
using ld = long double;
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > string toString(T a)       { return to_string(a); }  // Convert int to string
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}  // Convert string to int

ll add(ll x, ll y) { x += y; if(x >= mod) x -= mod; return x; }
ll sub(ll x, ll y) { x -= y; if(x < 0) x += mod; return x; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }

ll powr(ll a, ll b) {
    ll x = 1LL;
    while(b) {
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}

ll inv(ll a) { return powr(a, mod - 2); }
const int inv2 = (mod + 1) >> 1;
const ll INF =  1e18;
const int inf = 1e9;

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;
    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

/*********************************************START**************************************************************/
const int N = 100005;
int parent[N];
int size[N];
int ranks[N];

void init()
{
    for(int i = 0; i < N; i ++) {
        parent[i] = i;
        size[i] = 1;
    }
}

int Find(int k)
{
    if(parent[k] != k) {
        parent[k] = Find(parent[k]);
    }
    return parent[k];
}

int Union(int a, int b) 
{
    int x = Find(a);
    int y = Find(b);
    if(x == y) {
        return 0;
    }
    int d = size[x] * size[y];
    if(ranks[x] > ranks[y]) {
        size[x] += size[y];
        parent[y] = x;
    }
    else if(ranks[x] < ranks[y]) {
        size[y] += size[x];
        parent[x] = y;
    }
    else {
        size[y] += size[x];
        parent[x] = y;
        ranks[y] ++;
    }
    return d;
}

int main()
{
    ifalse;
    ll n, m;
    cin >> n >> m;
    init();
    vector < pair < int, int > > v;
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        v.pb({x, y});
    }

    vector < ll > ans1;
    ll ans = n * (n - 1) / 2;
    for(int i = m - 1; i >= 0; i --) {
        if(ans <= 0) ans = 0;
        ans1.pb(ans);
        if(ans > 0) {
            ll d = Union(v[i].first, v[i].second);
            ans -= d;
        }
    }
    for(int i = m - 1; i >= 0; i --) {
        cout << ans1[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 4212