#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

class UnionFind
{
public:
    UnionFind(int size) : m_Nodes(size)
    {
        Init();
    }

    void Init()
    {
        for (int i = 0, size = m_Nodes.size(); i < size; ++i)
        {
            m_Nodes[i].Init(i);
        }
    }

    int Root(int x)
    {
        const int parent = m_Nodes[x].m_Parent;
        if (parent == x)
        {
            return x;
        }
        else
        {
            return m_Nodes[x].m_Parent = Root(parent);
        }
    }

    bool Same(int x, int y)
    {
        return Root(x) == Root(y);
    }

    bool Unite(int x, int y)
    {
        x = Root(x);
        y = Root(y);

        if (x == y) return false;

        if (m_Nodes[x].m_Rank < m_Nodes[y].m_Rank)
        {
            m_Nodes[x].m_Parent = y;
            m_Nodes[y].m_Size += m_Nodes[x].m_Size;
        }
        else
        {
            m_Nodes[y].m_Parent = x;
            m_Nodes[x].m_Size += m_Nodes[y].m_Size;
            if (m_Nodes[x].m_Rank == m_Nodes[y].m_Rank) ++m_Nodes[x].m_Rank;
        }

        return true;
    }

    int Size(int x)
    {
        return m_Nodes[Root(x)].m_Size;
    }

private:
    struct Node
    {
    public:
        void Init(int index)
        {
            m_Parent = index;
            m_Rank = 0;
            m_Size = 1;
        }

        int m_Parent = -1;
        int m_Rank = -1;
        int m_Size = -1;
    };

    vector<Node> m_Nodes;
};

const int MAX_N = 100005;

int main()
{
    UnionFind uf(MAX_N);

    LL N, M;
    cin >> N >> M;
    vector<pii> edges;
    LL A, B;
    REP(i, M)
    {
        cin >> A >> B;
        edges.push_back(make_pair(A, B));
    }
    reverse(edges.begin(), edges.end());
    vector<LL> conveniences;
    for (const auto& edge : edges)
    {
        LL a = edge.first;
        LL b = edge.second;
        if (uf.Same(a, b))
        {
            conveniences.push_back(0);
        }
        else
        {
            conveniences.push_back((LL)uf.Size(a) * uf.Size(b));
            uf.Unite(a, b);
        }
    }
    reverse(conveniences.begin(), conveniences.end());
    LL inconvenience = 0;
    REP(i, M)
    {
        inconvenience += conveniences[i];
        cout << inconvenience << endl;
    }
    return 0;
}


Measured memory_bytes: 4212