#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

vector<pair<int,int> > edge;
vector<int> ans;
int n, m, p[100005];
int f(int u){
	return (p[u] < 0 ? u : p[u] = f(p[u]));
}
void j(int u,int v){
	u = f(u); v = f(v);
	if(u == v) return;
	if(p[u] > p[v]) swap(u, v);
	p[u] += p[v];
	p[v] = u;
}
signed main(){
	cin >> n >> m;
	for(int i = 1 ; i <= n ; i ++)
		p[i] = -1;
	for(int i = 1 ; i <= m ; i ++){
		int u, v;
		cin >> u >> v;
		edge.push_back({u, v});
	}
	int cur = n*(n - 1)/2;
	ans.push_back(cur);
	for(int i = m - 1 ; i >= 1 ; i --){
		int u = edge[i].first, v = edge[i].second;
		u = f(u), v = f(v);
		if(u == v) {
			ans.push_back(cur);
		} else{
			cur -= p[u]*p[v];
			j(u, v);
			ans.push_back(cur);
		}
	}
	for(int i = ans.size() - 1 ; i >= 0 ; i --)
		cout << ans[i] << endl;
}