#include<bits/stdc++.h>
using namespace std;
const int size=100000;
long N,M;//N:vertex M:edge
int relate[size];int par[size];
int root(int v){
	if(relate[v]==v){
		return v;
	}else{
		return root(relate[v]);
	}
}
void unite(int x,int y){//union by size
	x=root(x);y=root(y);
	if(x==y){
		return;
	}else if(par[x]<par[y]){
		swap(x,y);
	}relate[y]=x;
	par[x]+=par[y];
	return;
}
int main(){
	cin>>N>>M;
	int A[M],B[M];long ans[M];
    long result=N*(N-1)/2;
	long a,b;
	for(int i=0;i<M;i++){
		cin>>A[i]>>B[i];
		A[i]--;B[i]--;
	}for(int i=0;i<N;i++){//initialize
		relate[i]=i;
        par[i]=1;
	}for(int i=M-1;i>=0;i--){
		ans[i]=result;
        a=root(A[i]);b=root(B[i]);
        if(a!=b){
            result-=par[a]*par[b];
            unite(a,b);
		}
	}for(int j=0;j<M;j++){
		cout<<ans[j]<<endl;
	}
}