/////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																													   
#include <iostream>       	
#include <cstdio>         
#include <limits>		  
#include <cstdlib>       
#include <utility>        
#include <iterator>       
#include <bitset>         
#include <list>           
#include <vector>
#include <map>
#include <unordered_map>
#include <set>            														   
#include <queue>          																							   
#include <deque>          																							   
#include <stack>																									   
#include <algorithm>																								   
#include <cmath>																									   
#include <string>      																								   
#include <time.h>																									   
#include <iomanip> 																									   
#include <sstream>																									   
#include <bits/stdc++.h>																							   
	
using namespace std; 	
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   
//list<int>::iterator it;																								   
list<int>::iterator it1;																							   
vector<int>::iterator it2;																							   
vector<int>::iterator it3;																							   
set<int>::iterator it4;																								   
map<string, int>::iterator it5; 																					   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

pair<LL, LL> p[1000005];

LL n, m;
LL par[1000005];
LL s[1000005];
LL suma;
LL ans[1000005]; 

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

LL find(LL x){
	return par[x] == x ? x : par[x] = find(par[x]);		
}


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(false); cin.tie(NULL);    
	
	cin >> n >> m;
	
	for(int i = 1; i <= n; i++){
		par[i] = i;
		s[i] = 1;
	}
	
	for(int i = 0; i < m; i++){
		int v1, v2;
		cin >> v1 >> v2;
		p[i].first = v1;
		p[i].second = v2;
	}
	//cout << endl; //delete here
	suma = 1LL * n * (n - 1) / 2;
	for(int i = m - 1; i >= 0; i--){
		//cout << "i: " << i << endl;
		ans[i] = suma;
		int x = find(p[i].first);
		int y = find(p[i].second);
		if(x != y){
			par[y] = x;
			//cout << "s[x]: " << s[x] << endl;
			//cout << "s[y]: " << s[y] << endl;
			//cout << "s[x] * x[y]: " << s[x] * s[y] << endl << endl;
			suma -= s[x] * s[y];
			s[x] += s[y];
		}
	}
	
	for(int i = 0; i < m; i++){
		cout << ans[i] << endl;
	}
	

}              							


Measured memory_bytes: 14464