var rooter;
const ROOT = -1;

function connected(a,b){
	a--;b--;
	let c = getRoot(a);
	let d = getRoot(b);
	let size = rooter[c] + rooter[d];
	let count = rooter[c] * rooter[d];
	rooter[c] = size;
	rooter[d] = c;
	//console.log(a,b);
	//console.log(c,d);
	//console.log(rooter[c],rooter[d]);
	//console.log(size,count);
	return count;
}
function getRoot(a){
	while(rooter[a]>ROOT){
		a = rooter[a];
	}
	return a;
}

function Main(input){
	'use strict'
	let temp = input.trim().split("\n");
	let temp2 = temp[0].split(" ");
	let N = parseInt(temp2[0]);
	let M = parseInt(temp2[1]);	
	temp.shift();

	const AB = temp.map( (v)=>
		v.split(" ").map( (w)=>
			parseInt(w)
		)
	);


	//全ての橋がない時の数を計算
	let huben = 0;
	for(var i=1;i<N;i++){
		huben += i;
	}

	//ルートがない状態
	rooter = new Array(N).fill(ROOT);
	
	//
	const answer = [huben];
	for(var i=AB.length-1;i>=0;i--){
		if(huben > 0){
			huben -= connected(AB[i][0],AB[i][1]);
		}
		answer.push(huben);
		//console.log(AB[i],"huben:",huben,"rooter:",rooter);
	}
	//console.log("----------------------------");
	//console.log("answer:",answer);
	//console.log(rooter);

	for(var i=answer.length-2;i>=0;i--){
		console.log(answer[i]);
	}

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));