#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

typedef long long ll;
const ll mod=1e9+7;
const int nax=1e5+10;

int par[nax];

inline int root(int v){return par[v] < 0 ? v : (par[v] = root(par[v]));}

inline int merge(int x,int y){
    if((x = root(x)) == (y = root(y))) return 0 ;
	if(par[y] < par[x])	swap(x, y);
	par[x] += par[y];
	par[y] = x;
	return 1;
}

int main(){
	FIO;
	ll n,m;
	cin>>n>>m;
	pair<int,int>a[m];
	for (int i = 0; i < nax; ++i) par[i]=-1;
	for (int i = 0; i < m; ++i) cin>>a[i].first>>a[i].second;
	ll ans[m],tot=(n*(n-1))/2;
	for(int i=m-1;i>=0;--i){
		ans[i]=tot;
		ll x=root(a[i].first),y=root(a[i].second);
		if(x==y) continue;
		x=-par[x],y=-par[y],tot-=x*y,merge(a[i].first,a[i].second);
	}
	for (int i = 0; i < m; ++i) cout<<ans[i]<<'\n';
	return 0;
}
