/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-07 19:43:12
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  size_t n = vec.size();
  for (size_t i = 0; i < n; ++i) {
    os << vec[i];
    if (i != n - 1) os << ',';
  }
  os << '}';
  return os;
}
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  os << '{';
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    os << '{' << it->first << ':' << it->second << '}';
    if (it != --mp.end()) os << ',';
  }
  os << '}';
  return os;
}
template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  os << '{';
  for (auto it = st.begin(); it != st.end(); ++it) {
    os << *it;
    if (it != --st.end()) os << ',';
  }
  os << '}';
  return os;
}
template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  size_t n = vec.size();
  for (size_t i = 0; i < n; ++i) is >> vec[i];
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

class UnionFind {
 public:
  UnionFind(int n) : n_(n) { initialize(); }

  int root(int x) {
    if (parent_[x] < 0)
      return x;
    else
      return parent_[x] = root(parent_[x]);
  }

  bool same(int x, int y) { return root(x) == root(y); }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (parent_[x] > parent_[y]) std::swap(x, y);
    parent_[x] += parent_[y];
    parent_[y] = x;
    return;
  }

  int size(int x) { return -parent_[root(x)]; }

 private:
  const int n_;
  std::vector<int> parent_;

  void initialize() { parent_.assign(n_, -1); }
};

void ABC120_D() {
  int n, m;
  cin >> n >> m;
  int64 ans = int64{n} * int64{n - 1} / 2;

  UnionFind uf(n);

  vector<pair<int, int>> in;

  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    in.emplace_back(a, b);
  }

  reverse(in.begin(), in.end());

  vector<int64> v;

  v.emplace_back(ans);

  for (int i = 0; i < m; ++i) {
    if (uf.same(in[i].first, in[i].second)) {
      ;
    } else {
      ans -= uf.size(in[i].first) * uf.size(in[i].second);
      uf.unite(in[i].first, in[i].second);
    }
    v.emplace_back(ans);
  }

  reverse(v.begin(), v.end());

  for (int i = 1; i < m + 1; ++i) {
    cout << v[i] << '\n';
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  ABC120_D();

  return 0;
}

Measured memory_bytes: 3444