#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,fa[100005],s[100005],e[100005],siz[100005];
typedef long long ll;
ll cur,ans[100005];
int find(int x){
    if(fa[x]==x) return x;
    return fa[x]=find(fa[x]);
}
inline ll calc(ll x){return x*(x-1)/2;}
int main()
{
    scanf("%d%d",&n,&m); 
    for(int i=1;i<=m;i++) scanf("%d%d",s+i,e+i);
    for(int i=1;i<=n;i++) fa[i]=i,siz[i]=1;
    ll tot=calc(n);
    ans[m+1]=tot;
    for(int i=m;i>1;i--){
        int a=find(s[i]),b=find(e[i]);
        if(siz[a]<siz[b]) swap(a,b);
        if(a!=b) {fa[b]=fa[a];
        cur-=calc(siz[a]);
        cur-=calc(siz[b]);
        siz[a]+=siz[b];siz[b]=0;
        cur+=calc(siz[a]);}
        ans[i]=tot-cur;
    }
    for(int i=2;i<=m+1;i++) printf("%lld\n",ans[i]);
    return 0;
}