#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
ll par[N],siz[N];
ll dsu_parent(ll node){
    if(node==par[node])return node;
    return par[node]=dsu_parent(par[node]);
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;cin>>n>>m;
    for(ll i=1;i<=n;i++)siz[i]=1,par[i]=i;

    vector< pair<ll,ll> >edges(m);
    for(ll i=0;i<m;i++)cin>>edges[i].first>>edges[i].second;
    ll ans[m];
    ans[m-1]=(n*(n-1))/2;
    for(ll i=m-2;i>=0;i--){
        ll a = dsu_parent(edges[i+1].first);
        ll b = dsu_parent(edges[i+1].second);
        if(a==b)ans[i]=ans[i+1];
        else{
            ans[i] = ans[i+1] - siz[a]*siz[b];
            if(siz[a]<siz[b])swap(a,b);
            par[b]=a;
            siz[a]+=siz[b];
        }
    }

    for(ll i=0;i<m;i++)cout<<ans[i]<<"\n";
}


