#include <bits/stdc++.h>
using namespace std;


int n,m,A[100001],B[100001], parent[100001];
long long f[100001],size[100001];

int find(int a){
	if(parent[a]==a){
		return a;
	}
	return find(parent[a]);
}
void uni(int a, int b){
	int ap=find(a);
	int bp=find(b);
	if(ap!=bp){
		if(size[ap]>size[bp]){
			parent[bp]=ap;
		}else{
			parent[ap]=bp;
		}
		size[ap]+=size[bp];
		size[bp]=size[ap];
	}
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>A[i]>>B[i];
	}
	for(int i=1;i<=n;i++){
		parent[i]=i;
		size[i]=1;
	}
	long long ans=(long long)n*(n-1)/2;
	for(int i=m;i>=1;i--){
		f[i]=ans;
		if(find(A[i])!=find(B[i])){
			//cout<<size[find(A[i])]<<" "<<size[find(B[i])]<<endl;
			ans=ans-(long long)size[find(A[i])]*size[find(B[i])];
		}
		uni(A[i],B[i]);
	}
	
	for(int i=1;i<=m;i++){
		cout<<f[i]<<endl;
	}
}