#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
typedef long long ll;
ll fa[maxn];
int T;
struct Node
{
    ll x,y;
}e[maxn];
int Find(int x)
{
    if(fa[x]==x)
        return x;
    else
        return fa[x]=Find(fa[x]);
}
ll x,y,n,m;
ll sum;
ll ans[maxn],f[maxn];
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)
        fa[i]=i,f[i]=1;
    for(int i=1;i<=m;i++)
    {
        scanf("%lld%lld",&e[i].x,&e[i].y);
    }
    sum=n*(n-1)/2;
    for(int i=m;i>=1;i--)
    {

        ans[i]=sum;
        x=e[i].x,y=e[i].y;
        x=Find(x);

        y=Find(y);
        if(x==y)
            continue;

        fa[y]=x;
        sum-=f[x]*f[y];
        f[x]+=f[y];
        //ans[i]=sum;
        //cout<<"====="<<endl;
    }
    for(int i=1;i<=m;i++)
       printf("%lld\n",ans[i]);
}
