import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
 
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 = N.iota().array;
	long[] size = repeat(1L, N).array;
	
	ulong root(ulong island) {
		auto parent = list[island];
		return parent == island ? island : ( list[island] = root(list[island]) ) ;
	}
	
	
	ulong unite(ulong island1, ulong island2) {
		auto root1 = root(island1), root2 = root(island2);
		if (root1 == root2) return 0;
		else {
			auto result = size[root1] * size[root2];
			list[root1] = root2;
			size[root2] += size[root1];
			return result;
		}
	}
	
	long[] results; results ~= N * (N-1) / 2;
	foreach_reverse(bridge; 1 .. M) {
		results ~= results[$-1] - unite(A[bridge]-1, B[bridge]-1);
	}
	foreach_reverse(num; results) { writeln(num); }
}

