'use strict';
// d
class Main {
  solve() {
    const nums = input.nextIntArr();
    const table = input.nextIntRange(nums[1]);
    const uf = new UnionFind(nums[0],['count']);
    table.reverse();
    let remain = nums[0] * (nums[0] - 1) / 2;
    const result = [];
    const counts = [...Array(nums[0])].map((e) => 1);
 
    for (const node of table) {
      result.push(remain);
      const n = node.map(e=>e-1);
      remain -= (uf.same(...n) ? 0 : (uf.size(n[0]) * uf.size(n[1])));
      uf.unite(...n);
    }
    console.log(result.reverse().join('\n'));
  }
}
 
class Unit {
  constructor(name) { this.name = name; this.data = []; }
  get(rx) { return this.data[rx]; }
  set(x,value) { this.data[x] = value; return this.data[x]; }
  set init(func) { this._init = func; }
  set union(func) { this._union = func; }
  get init() { return this._init; }
  get union() { return this._union }
}
 
class UnionFind {
  constructor(n, options) {
    this.units = {};
    this.units['ref'] = UnionFind._ref;
    for (const o of options) {
      if (o === 'count') { this.units['count'] = UnionFind.Counter; }
      else if (o instanceof Unit) { this.units[o.name] = o; }
    }
    for (const name in this.units) {
      const unit = this.units[name];
      for (let i = 0;i < n; ++i) { unit.init(i); }
    }
  }
 
  root(x) {
    if (this.units.ref.get(x) == x) return x;
    return this.units.ref.set(x, this.root(this.units.ref.get(x)));
  }
 
  get(name, x) {
    return this.units[name].get(this.root(x));
  }
  size(x) { return this.get('count', x); }
 
  unite(x, y) { // xとyの木を併合
    const rx = this.root(x); const ry = this.root(y);
    const rmax = Math.max(rx,ry); const rmin = Math.min(rx,ry);
    for (const name in this.units) { 
      const u = this.units[name];
      u.union(x,y,rmin,rmax); 
    }
    return true;
  }
 
  same(x, y) { // 2つのデータx, yが属する木が同じならtrueを返す
    const rx = this.root(x);
    const ry = this.root(y);
    return rx == ry;
  } 
 
  static get _ref() {
    const u = new Unit('ref');
    u.init = ((i) => u.data[i] = i);
    u.union = ((x,y,rmin,rmax) => {
      if (rmax == rmin) return;
      u.data[rmax] = rmin;
    });
    return u;
  }
 
  static get Counter() {
    const u = new Unit('count');
    u.init = ((i) => u.data[i] = 1);
    u.union = ((x,y,rmin,rmax) => {
      if (rmax == rmin) return;
      u.data[rmin] = u.data[rmax] + u.data[rmin];
    });
    return u;
  }
}
 
class Input {
  constructor() {
    this.cursor = 0;
    this.inputAll();
  }
 
  inputAll() {
    this.data = (require("fs").readFileSync("/dev/stdin", "utf8")).split('\n');
    return this.data;
  }
 
  nextLine(n) {
    if (n) {
      const ret = this.data.slice(this.cursor, this.cursor + n);
      this.cursor += n;
      return ret;
    }
    return this.data[this.cursor++];
  }
 
  nextStrArr() {
    return this.nextLine().split(' ');
  }
 
  nextIntArr() {
    return this.nextStrArr().map((e) => parseInt(e));
  }
 
  nextStrRange(n) {
    return this.nextLine(n).map((line) => line.split(' '));
  }
 
  nextIntRange(n) {
    return this.nextLine(n).map((line) => line.split(' ').map((e) => parseInt(e)));
  }
}
const input = new Input();
 
(new Main()).solve();

Measured memory_bytes: 66700