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!long(), N = data[0].to!long();
	long[] A, B;
	foreach (i; 0 .. M) {
		data = readln().split();
		B ~= data[1].to!long(), A ~= data[0].to!long();
	}
	
	long[][] list; list.length = M;		// list[group] = [the list of bridges]
	foreach (bridge; 0 .. M) { list[bridge] ~= [bridge]; }
	
	long find_bridge(long bridge) {
		foreach (group_number, bridges; list) {
			if (!find(bridges, bridge).empty) return group_number;
		}
		return 0;
	}
	
	long unite(long group1, long group2) {
		//writeln("group", group1, ", ", group2);
		if (group1 == group2) return 0;
		
		auto n1 = list[group1].length, n2 = list[group2].length;
		list[group1] ~= list[group2];
		list = list[0 .. group2] ~ list[group2+1 .. $];
		return n1*n2;
	}
	
	long[] results; long result = N * (N-1) / 2;
	foreach_reverse (bridge; 0 .. M) {
		results ~= result;
		auto group1 = find_bridge(A[bridge]-1), group2 = find_bridge(B[bridge]-1);
		result -= unite(group1, group2);
	}
	
	foreach_reverse(a; results) {
		writeln(a);
	}
	
}

