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

const int N=1e6+5;
int n,m,fa[N],sz[N];
long long pr,ans[N];
pair<int,int> p[N];

int getfa(int x)
{
	if(fa[x]!=x) fa[x]=getfa(fa[x]);
	return fa[x];
}

int main()
{
	int i;
	scanf("%d%d",&n,&m);
	ans[m]=pr=1LL*n*(n-1)>>1;
	for(i=1;i<=n;++i) fa[i]=i,sz[i]=1;
	for(i=1;i<=m;++i) scanf("%d%d",&p[i].first,&p[i].second);
	for(i=m;i>1;--i)
	{
		int fx=getfa(p[i].first);
		int fy=getfa(p[i].second);
		if(fx==fy)
		{
			ans[i-1]=pr;
			continue;
		}
		pr-=1LL*sz[fx]*sz[fy];
		sz[fx]+=sz[fy];
		fa[fy]=fx;
		ans[i-1]=pr;
	}
	for(i=1;i<=m;++i) printf("%lld\n",ans[i]);
	return 0;
}