import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

丈夫な橋から潤に採用していき、Union-findしていく

その時点でつながっているものを数える

全体からひけば答え

*/

class Edge{
	Node node1;
	Node node2;
	long value;
	this(Node node1, Node node2, long value){
		this.node1 = node1, this.node2 = node2;
		this.value = value;
	}
}

class Node{
	long id;
	long value;
	Group group;
	this(long id, long value){
		this.id = id;
		this.value = value;
	}
}

class Group{
	long value;
	long pendingEdgeCount;
	long id;
	Node[] nodes;
	this(Node node){
		this.id = node.id;
		this.nodes = [node];
		this.value = node.value;
	}
	void eat(Group gp){
		if(gp.nodes.length > this.nodes.length) gp.eat(this);
		else{
			foreach(nd; gp.nodes){
				this.nodes ~= nd;
				nd.group = this;
				this.value += nd.value;
			}
			this.pendingEdgeCount += gp.pendingEdgeCount;
		}
	}
}

void main(){
	long n = read.to!long;
	long m = read.to!long;
	
	Node[] nodes;
	foreach(i; 0 .. n) nodes ~= new Node(i, 0);
	
	foreach(nd; nodes){
		nd.group = new Group(nd);
	}
	
	Edge[] edges;
	foreach(i; 0 .. m){
		long a = read.to!long - 1;
		long b = read.to!long - 1;
		
		edges ~= new Edge(nodes[a], nodes[b], i);
	}
	
	edges.sort!"a.value>b.value"();
	
	long[] answers;
	long total = n * (n - 1) / 2;
	long okcount = 0;
	foreach(ed; edges){
		answers ~= total - okcount;
		if(ed.node1.group.id != ed.node2.group.id){
			okcount += ed.node1.group.nodes.length * ed.node2.group.nodes.length;
			ed.node1.group.eat(ed.node2.group);
		}
	}
	
	foreach_reverse(ans; answers) ans.writeln;
	
}
