#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
class UnionFind {
 private:
  vector<int> par;
  vector<int> sizes;

 public:
  UnionFind(int n) {
    par = vector<int>(n);
    sizes = vector<int>(n);
    for (int i = 0; i < n; i++) {
      par[i] = i;
      sizes[i] = 1;
    }
  }
  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return sizes[find(x)]; }
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  UnionFind uni(n);
  vector<ll> ans(m);
  ans[m - 1] = (ll)n * (n - 1) / 2;
  for (int i = m - 1; i >= 1; i--) {
    ans[i - 1] = ans[i];
    if (!uni.same(a[i], b[i])) {
      ans[i - 1] -= (ll)uni.size(a[i]) * uni.size(b[i]);
      uni.unite(a[i], b[i]);
    }
  }
  for (int i = 0; i < (int)(m); i++) cout << ans[i] << endl;
  return 0;
}
