#include <bits/stdc++.h>
using namespace std;
vector<unordered_set<int>> cc;
int findVertex(int v) {
  for (int i = 0; i < cc.size(); ++i) {
    if (cc[i].count(v) > 0) {
      return i;
    }
  }
  return -1;
}
int main() {
  long long n = 0, m = 0;
  cin >> n >> m;
  vector<int> vs;
  vector<int> ve;
  for (int i = 0; i < m; ++i) {
    int s = 0, e = 0;
    cin >> s >> e;
    vs.push_back(s);
    ve.push_back(e);
  }
  long long total = n * (n - 1) / 2;
  vector<long long> answers;
  for (int i = 1; i <= n; ++i) {
    unordered_set<int> iset;
    iset.insert(i);
    cc.push_back(iset);
  }
  answers.push_back(total);
  long long curTotal = 0;
  for (long long i = m - 1; i >= 0; --i) {
    int posSi = findVertex(vs[i]);
    int posEi = findVertex(ve[i]);
    if (posSi == posEi) {
      answers.push_back(total - curTotal);
      continue;
    }
    long long cs = (cc[posSi].size() * (cc[posSi].size() - 1)) / 2;
    long long ce = (cc[posEi].size() * (cc[posEi].size() - 1)) / 2;
    curTotal -= cs + ce;
    for (unordered_set<int>::iterator it = cc[posEi].begin();
         it != cc[posEi].end(); ++it) {
      cc[posSi].insert(*it);
    }
    cc[posEi].clear();
    curTotal += (cc[posSi].size() * (cc[posSi].size() - 1)) / 2;
    answers.push_back(total - curTotal);
  }
  for (int i = int(answers.size()) - 2; i >= 0; --i) {
    cout << answers[i] << endl;
  }
  return 0;
}
