#ifndef __UNION_FIND_H__
#define __UNION_FIND_H__

#include <vector>

class UnionFindTree {
	const int size_m;					// 頂点数
	mutable std::vector<int> parent_m;	// 親の添字, 根である場合は自身の添字を入れる
	std::vector<int> count_m;			// 部分木のサイズ

	bool Is_valid_index(int i) const;
public:
	UnionFindTree(int size);

	int Root_of(int i) const;
	bool Is_same(int i, int j) const;
	void Unite(int i, int j);

	int Size() const;
	int Group_size(int i) const;
	std::vector<std::vector<int> > Get_groups() const;
};

#endif

#if ONLY_MY_ENVIR
#include "UnionFind.h"
#endif

#include <cassert>
#include <utility>
#include <algorithm>

UnionFindTree::UnionFindTree(int size) 
	: size_m(size), parent_m(size), count_m(size, 1) {
	for (int i = 0; i < size; ++i) {
		parent_m[i] = i;
	}
}

bool UnionFindTree::Is_valid_index(int i) const {
	return i >= 0 && i < Size();
}

int UnionFindTree::Root_of(int i) const {
	assert(Is_valid_index(i));

	if (parent_m[i] == i) return i;
	return parent_m[i] = Root_of(parent_m[i]);
}

bool UnionFindTree::Is_same(int i, int j) const {
	assert(Is_valid_index(i) && Is_valid_index(j));

	int ri = Root_of(i);
	int rj = Root_of(j);
	return ri == rj;
}

void UnionFindTree::Unite(int i, int j) {
	assert(Is_valid_index(i) && Is_valid_index(j));

	int ri = Root_of(i);
	int rj = Root_of(j);

	if (ri == rj) return;
	if (count_m[ri] > count_m[rj]) {
		std::swap(ri, rj);
	}

	// assert(count_m[ri] <= count_m[rj])
	parent_m[ri] = rj;
	count_m[rj] += count_m[ri];
}

int UnionFindTree::Size() const {
	return size_m;
}

/* 頂点 i の属する集合のサイズ */
int UnionFindTree::Group_size(int i) const {
	assert(Is_valid_index(i));

	int ri = Root_of(i);
	return count_m[ri];
}

std::vector<std::vector<int> > UnionFindTree::Get_groups() const {
	std::vector<std::vector<int> > groups(size_m);

	for (int i = 0; i < size_m; ++i) {
		int ri = Root_of(i);
		groups[ri].push_back(i);
	}

	std::vector<std::vector<int>> ret;
	for (int i = 0; i < size_m; ++i) {
		if (groups[i].empty()) continue;
		ret.push_back(groups[i]);
	}
	return ret;
}
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i, a, n) for(LL i = (a), i##_max = (n); i < i##_max; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##min = (a); i >= i##min; --i)
#define ALL(arr) (arr).begin(), (arr).end()
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
template <class T>
T Next() { T buf; cin >> buf; return buf; }

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "UnionFind.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "FlowSolver.h"
#include "Tree.h"
#include "SuffixArray.h"
#include "Matrix.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "BIT.h"
#include "Rational.h"
#include "Position.h"
#include "Factorization.h"
#include "Math.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
// template <class T>
// auto Is(const T& value) { return [value](const auto& comparand) -> bool { return comparand == value; }; }
#endif

int N, M;
int A[100000];
int B[100000];
LL S[100000];
int main() {
	cin >> N >> M;
	REP(j, 0, M) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		A[j] = a;
		B[j] = b;
	}
	
	UnionFindTree uf(N);
	LL ans = (LL)N * (N - 1) / 2;
	REM(j, 0, M) {
		S[j] = ans;

		int a = A[j];
		int b = B[j];
		if (uf.Is_same(a, b)) continue;
		int p = uf.Group_size(a);
		int q = uf.Group_size(b);
		ans -= (LL)p * q;
		uf.Unite(a, b);
	}

	REP(j, 0, M) {
		cout << S[j] << endl;
	}
	return 0;
}


Measured memory_bytes: 3712