#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL n,rnk[100001],cnt;
int m,p[100001],b[100001],a[100001];
int fnd(int a){
	if(p[a]!=a)
		return p[a]=fnd(p[a]);
	return a;
}
int main(){
	vector<LL> ans;
	LL o=0;
	cin>>n>>m;
	cnt=(n-1)*n/2;
	ans.push_back(cnt);
	for(int i=0;i<n;i++){
		rnk[i]=1;
		p[i]=i;
	}
	for(int i=0;i<m;i++)
		scanf("%d%d",a+i,b+i);
	reverse(a,a+m);
	reverse(b,b+m);

	for(int i=0;i<m-1;i++){
		a[i]--;b[i]--;
		int pa=fnd(a[i]);
		int pb=fnd(b[i]);
		if(pa==pb){
			ans.push_back(cnt-o);
			continue;
		}
		o+=rnk[pa]*rnk[pb];
		ans.push_back(cnt-o);
		rnk[pa]+=rnk[pb];
		rnk[pb]=0;
		p[pb]=pa;
	}
	reverse(ans.begin(),ans.end());
	for(auto a:ans)
		cout<<a<<"\n";

}

