#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,m;
pair<int,int>p[maxn];
int fa[maxn];
ll siz[maxn];
ll ans[maxn],cnt;
int fi(int x){
    if(x==fa[x])return x;
    return fa[x]=fi(fa[x]);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)fa[i]=i,siz[i]=1;
    for(int i=1;i<=m;i++)scanf("%d%d",&p[i].first,&p[i].second);
    ans[++cnt]=1ll*n*(n-1)/2;
    for(int i=m;i>1;i--){
        int f1=fi(p[i].first),f2=fi(p[i].second);
        if(f1==f2)cnt++,ans[cnt]=ans[cnt-1];
        else{
            cnt++;
            ans[cnt]=ans[cnt-1]-(siz[f1]*siz[f2]);
            fa[f1]=f2;siz[f2]+=siz[f1];
        }
    }
    for(int i=cnt;i>=1;i--)printf("%lld\n",ans[i]);
}
