#include<iostream>
using namespace std;
int main() {
  long N, M, A[100001], B[100001];
  cin >> N >> M;
  for (int i = M;i > 0;-- i) cin >> A[i] >> B[i];
  long ans[100001], uf[100001];
  ans[0] = N * (N - 1) / 2;
  for (int i = 1;i <= N;++ i) uf[i] = -1;
  for (int i = 1, l, r;i <= M;++ i) {
    for (l = A[i];uf[l] >= 0;l = uf[l]);
    for (r = B[i];uf[r] >= 0;r = uf[r]);
    ans[i] = ans[i - 1];
    if (l != r) {
      ans[i] -= uf[l] * uf[r];
      if(uf[l] < uf[r]) {
        uf[l] += uf[r];
        uf[r] = l;
      } else {
        uf[r] += uf[l];
        uf[l] = r;
      }
    }
  }
  for (int i = M - 1;i >= 0;-- i) cout << ans[i] << endl;
  return 0;
}