#include <bits/stdc++.h>
using namespace std;
struct unionFind {
  vector<int> par;
  vector<int> sz;
  unionFind(int n) : par(n), sz(n) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
      sz[i] = 1;
    }
  }
  int root(int n) {
    if (n == par[n]) return n;
    return par[n] = par[par[n]];
  }
  bool issame(int x, int y) {
    int px = root(x);
    int py = root(y);
    return px == py;
  }
  void unite(int x, int y) {
    int px = root(x);
    int py = root(y);
    if (issame(px, py)) return;
    if (size(px) >= size(py)) swap(px, py);
    par[py] = px;
    sz[px] += sz[py];
    sz[py] = sz[px];
  }
  int size(int x) { return sz[x]; }
};
int main(void) {
  int N, M;
  cin >> N >> M;
  int A[M], B[M];
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    A[i] = a;
    B[i] = b;
  }
  unionFind uf = unionFind(N);
  int ans[M];
  ans[M - 1] = N * (N - 1) / 2;
  for (int i = M - 1; i >= 1; i--) {
    int x = A[i];
    int y = B[i];
    if (uf.issame(x, y))
      ans[i - 1] = ans[i];
    else {
      ans[i - 1] = ans[i] - uf.size(x) * uf.size(y);
      uf.unite(x, y);
    }
  }
  for (int i = 0; i < M; i++) cout << ans[i] << endl;
}
