'use strict';
// d
class Main {
  solve() {
    const nums = input.nextIntArr();
    const table = input.nextIntRange(nums[1]);
    const uf = new UnionFind(nums[0]);
    table.reverse();
    let remain = nums[0] * (nums[0] - 1) / 2;
    const result = [];
    result.push(remain);
    const counts = [...Array(nums[0])].map((e) => 1);

    for (const node of table) {
      const roots = node.map((e) => uf.root(e - 1));
      uf.unite(...roots);
      remain -= roots[0] == roots[1] ? 0 : counts[roots[0]] * counts[roots[1]];
      result.push(remain);
      counts[Math.min(...roots)] = counts[roots[0]] + counts[roots[1]];
    }
    console.log(result.reverse().slice(1).join('\n'));
  }
}

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)));
  }
}

class UnionFind {
  constructor(n) {
    this.ref = [];
    for (let i = 0;i < n; ++i) {
      this.ref[i] = i;
    }
  }

  root(x) {
    if (this.ref[x] == x) return x;
    return this.ref[x] = this.root(this.ref[x]);
  }

  unite(x, y) { // xとyの木を併合
    const rx = this.root(x);
    const ry = this.root(y);
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    this.ref[Math.max(rx,ry)] = Math.min(rx,ry); //xとyの根が同じでない(=同じ木にない)時, rx,ryの小さい方を根とする
  }

  same(x, y) { // 2つのデータx, yが属する木が同じならtrueを返す
    const rx = this.root(x);
    const ry = this.root(y);
    return rx == ry;
  } 
}

const input = new Input();
(new Main()).solve();
