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

  var islands = [];
  var pairs = [];
  var ans = [];
  for(var i=0;i<N;i++) islands[i] = new UnionFind(i);
  for(var i=0;i<M;i++){
    var A = input.shift()-1;
    var B = input.shift()-1;
    pairs.push([A,B]);
  }
  var tmp = N*(N-1)/2;
  pairs.reverse().forEach(v=>{
    w = islands[v[0]].marge(islands[v[1]]);
    ans.push(tmp);
    tmp-=w;
  })
  console.log(ans.reverse().join("\n"));
}
function UnionFind(x){
  this.parent = null;
  this.size = 1;
  this.no = x;
};
UnionFind.prototype.root = function(){
  if(this.parent == null) return this;
  else {
    return this.parent = this.parent.root();
  }
};

UnionFind.prototype.getSize = function(){
  if(this.parent == null) return this.size;
  else {
    return this.parent.getSize();
  }
};

UnionFind.prototype.marge = function(a){
  var base=this.root(), child=a.root();
  if(base===child) return 0;
  if(base.size < child.size){ [base,child]=[child,base]; }
  child.parent = base;
  var ans = base.size * child.size;
  child.size = base.size += child.size;
  return ans;
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
