#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> e(m);
  for (auto& x : e) {
    cin >> x.first >> x.second;
    x.first--;
    x.second--;
  }
  vector<int> par(n, -1);
  auto root = [&](int t) {
    if (par[t] < 0) return t;
    for (int i = t;; i = par[i])
      if (par[i] < 0) return par[t] = i;
  };
  vector<ll> ans;
  ll aa = (ll)n * (n - 1) / 2;
  ans.push_back(aa);
  for (int i = m; --i;) {
    int r1 = root(e[i].first), r2 = root(e[i].second), c1 = -par[r1],
        c2 = -par[r2];
    if (r1 != r2) {
      par[r1] -= c2;
      par[r2] = r1;
      aa -= (ll)c1 * c2;
    }
    ans.push_back(aa);
  }
  reverse(ans.begin(), ans.end());
  for (auto x : ans) cout << x << endl;
}
