#include<bits/stdc++.h>

#define ll long long
using namespace std;

const int _M=1e5+40;

ll a[_M],t[_M],ans[_M],k=0;

struct
{
    int x,y;
} e[_M];

int fd(int x)
{
    return x==a[x]?x:a[x]=fd(a[x]);//记得要压缩路径
}

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)a[i]=i,t[i]=1;
    for(int i=1; i<=m; i++)
        scanf("%d%d",&e[i].x,&e[i].y);
    ll an=(ll)n*(ll)(n-1)/2;   //当将int类型的变量运算后赋值给long long 类型的变量是记得要强转
    ans[k++]=an;
    for(int i=m; i>=1; i--)
    {
        int ra=fd(e[i].x),rb=fd(e[i].y);
        if(ra!=rb)
        {
            an-=((ll)t[ra]*(ll)t[rb]);
            t[ra]+=t[rb];
            a[rb]=ra;
        }
        ans[k++]=an;
    }
    k-=2;
    while(k>=0)
       cout<<ans[k--]<<endl;
    return 0;
}




