#include<cstdio>
#include<cstring>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
const int N=2e5+11;
int a[N],b[N],sz[N],fa[N];
int n,cnt,m;
long long Ans,ans[N];
inline int find(int x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main(){
	scanf("%d%d",&n,&m);
	Ans=1ll*(n-1)*n/2;
	rep(i,1,n)
		fa[i]=i,sz[i]=1;
	rep(i,1,m)
		scanf("%d%d",a+i,b+i);
	for(int i=m;i;--i){
		int x=a[i],y=b[i];
		x=find(x),y=find(y);
		ans[i]=Ans;
		if(find(x)==find(y));
		else{
			Ans-=1ll*sz[x]*sz[y];
			fa[x]=y;
			sz[y]+=sz[x];
		}
	}
	rep(i,1,m)
		printf("%lld\n",ans[i]);
	return 0;
}