import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
 
void main() {
	auto data = readln().split();
	auto M = data[1].to!int(), N = data[0].to!int();
	int[] A, B;
	foreach (i; 0 .. M) {
		data = readln().split();
		B ~= data[1].to!int(), A ~= data[0].to!int();
	}
	
	int[] list;	// list[bridge] = group;
	list.length = N;
	foreach (i; 0 .. N) { list[i] = i; }
	
	
	long[] results;
	foreach_reverse (bridge; 0 .. M) {
		
		auto list2 = list.dup;
		
		auto islands = group(list2.sort()).map!(x => x[1]).array;
		
		if (islands.length == 1) { results ~= 0; }
		else {
			long result = 0;
			foreach (num; islands) result += num * (N - num);
			results ~= result/2;
		}
		
		auto group1 = list[A[bridge]-1], group2 = list[B[bridge]-1];
		foreach (island; 0 .. N) if (list[island] == group2) list[island] = group1;
		
	}
	foreach_reverse(result; results) { writeln(result); }
	
}

