import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n)
	{
		par = new long[](n);
		foreach (i; 0..n) par[i] = i;
		cnt = new long[](n);
		fill(cnt, 1);
	}
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	long unite(long i, long j)
	{ 
		i = root(i); j = root(j);
		if (i == j) return 0;
		par[j] = i;
		auto cnt_i = ((cnt[i] ^^ 2) - cnt[i]) / 2;
		auto cnt_j = ((cnt[j] ^^ 2) - cnt[j]) / 2;
		cnt[i] += cnt[j];
		auto diff = ((cnt[i] ^^ 2) - cnt[i]) / 2 - (cnt_i + cnt_j);
		//stderr.writeln(i, ":", j, " ", cnt_i, " ", cnt_j, " ", diff);
		return diff;
	}

	long[] par;
	long[] cnt;
}

void main()
{
	auto N = RD;
	auto M = RD;
	auto ab = new long[2][](M);

	foreach (i; 0..M)
	{
		auto a = RD-1;
		auto b = RD-1;
		ab[i] = [a, b];
	}

	auto ans = new long[](M);
	UnionFind uf;
	uf.init(N);
	long cnt;
	long full = ((N ^^ 2) - N) / 2;
	foreach_reverse (i, e; ab)
	{
		ans[i] = full - cnt;
		cnt += uf.unite(e[0], e[1]);
	}

	foreach (e; ans)
		writeln(e);
	
	stdout.flush();
}