function main(input) {
  var input=input.trim().split(/\n/);
  var N = Number(input[0].split(" ")[0]);
  var M = Number(input[0].split(" ")[1]);

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

  var ans = [];
  var unionFind = new UnionFind(N);
  var tmp = N*(N-1)/2;
  var v, w;
  for(var i=pairs.length-1;i>=0;i--){
    v = pairs[i];
    w = unionFind.getSize(v[0])*unionFind.getSize(v[1]);
    ans.push(tmp);
    if(unionFind.marge(v[0], v[1])==1){
      tmp-=w;
    }
  }
  for(var i=ans.length-1;i>=0;i--){
    console.log(ans[i]);
  }
}
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.parent;
    return parentNode;
  }
  return this.nodes[x];
};
UnionFind.prototype.marge = function(ax,bx){
  var base = this.root(ax);
  var child = this.root(bx);
  if(base.parent==child.parent) return 0;
  var baseSize = this.getSize(base.no);
  var childSize = this.getSize(child.no);
  if(baseSize > childSize){
    child.parent = base.no;
    base.size += childSize;
  }else{
    base.parent = child.no;
    child.size += baseSize;
  }
  return 1;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
