function main(input) {
  var input=input.trim().split(/\s+/);
  var N = Number(input.shift());
  var M = Number(input.shift());

  var pairs = [];
  for(var i=0;i<M;i++){
    var A = input.shift()-1;
    var B = input.shift()-1;
    pairs.push([A,B]);
  }

  var ans = [];
  var unionFind = new UnionFind(N);
  var tmp = N*(N-1)/2;
  pairs.reverse().forEach(function(v){
    w = unionFind.getSize(v[0])*unionFind.getSize(v[1]);
    ans.push(tmp);
    if(unionFind.marge(v[0], v[1])==1){
      tmp-=w;
      console.log(v[0], v[1], unionFind.nodes);
    }
  });
  console.log(unionFind.nodes);
  console.log(ans.reverse().join("\n"));
}
function UnionFind(n){
  this.nodes = [];
  for(var i=0;i<n;i++){
    this.nodes[i] = {
      parent: i,
      size: 1,
      no: i,
    };
  }
};
UnionFind.prototype.getSize = function(x){
  var parentNode = this.root(x);
  return parentNode.size;
}
UnionFind.prototype.root = function(x){
  if(this.nodes[x].parent != x){
    var parentNode = this.root(this.nodes[x].parent);
    this.nodes[x].parent = parentNode.no;
    return parentNode;
  }
  return this.nodes[x];
};
UnionFind.prototype.marge = function(ax,bx){
  var base = this.root(ax);
  var child = this.root(bx);
  if(base.no==child.no) return 0;
  if(base.size > child.size){
    child.parent = base.no;
    base.size += this.getSize(child.no);
  }else{
    base.parent = child.no;
    child.size += this.getSize(base.no);
  }
  return 1;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
