#include<bits/stdc++.h>
#define ll long long
const int MAXN=1e5+5;
const int MOD=1e9+7;
using namespace std;
ll a[MAXN];
ll b[MAXN];
ll father[MAXN];
ll num[MAXN];
ll tmp[MAXN];
ll n ,m;
ll Find(ll x){
    if(father[x]!=x)
        father[x]=Find(father[x]);
    return father[x];
}

int main(){
	ll sum=0;
	scanf("%d%d",&n,&m);
	for(ll i=0;i<m;++i)
		scanf("%d%d",&a[i],&b[i]);
	sum=n*(n-1)/2;
	for(ll i=1;i<=n;i++){
		father[i]=i;
		num[i]=1; 
	}
	for(ll i=m;i>=0;--i){
		tmp[i]=sum;
		ll x=Find(a[i]);
		ll y=Find(b[i]);
		if(x!=y){
			sum-=num[x]*num[y];
			if(num[x]<num[y]) 
				swap(x,y);
			num[x]+=num[y];
			father[y]=x;
		}
	}
	for(ll i=0;i<=m-1;i++)
		printf("%lld\n", tmp[i]);
	return 0;
}
