#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 100010
namespace uf{
  ll p[N],s[N];
  void init(){
    for(int i=0;i<N;i++)p[i]=i,s[i]=1;
  }
  ll par(ll x){
    ll y=x,z;
    while(x!=p[x])x=p[x];
    while(y!=x)z=p[y],p[y]=x,y=z;
    return x;
  }
  ll unite(ll a,ll b){
    a=par(a); b=par(b);
    if(a==b)return 0;
    ll res=s[a]*s[b];
    p[b]=a,s[a]+=s[b];
    return res;
  }
};
ll n,m,a[N],b[N],ans[N];
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++)cin>>a[i]>>b[i];
    uf::init();
    ll cur=n*(n-1)/2;
    for(int i=m-1;~i;i--){
      ans[i]=cur;
      cur-=uf::unite(a[i],b[i]);
    }
    for(int i=0;i<m;i++)cout<<ans[i]<<endl;
    return 0;
}

