#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

struct UnionFind {
    
    vector < int > node;
    UnionFind(int n) : node(n, -1) {}
    
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (node[y] < node[x]) swap(x, y);
            node[x] += node[y];
            node[y] = x;
        }
        return x != y;
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    int root(int x) {
        return node[x] < 0 ? x : node[x] = root(node[x]);
    }
    
    int size(int x) {
        return -node[root(x)];
    }
    
};
/*
 usage:
 
 初期化:
 UnionFind  UF(N);//ノードの数
 unite(x,y);// xとyノード連結
 same(a,b);// aとbが同じ所属かどうかを判別
 root(a); //aのルートのノードを計算
 */

ll N , M ;
vector<pair<ll,ll> > brige;
map<ll,ll> siz;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> M ;
    rep(i, M){
        ll A, B;
        cin >> A >> B ;
        brige.pb(mp(A,B));
    }
    
    UnionFind UF(N+1);
    rep(i, N+1){
        siz[i] = 1;
    }
    
    vector<ll> ans;
    
    for(ll i = M-1; i >= 0 ; i--){
        ll A = brige[i].first;
        ll B = brige[i].second;
        ll A_root = UF.root(A);
        ll B_root = UF.root(B);
        
//        cerr << "---combine: " << A << " " << B << endl;
        if(A_root != B_root){
            ll A_siz = siz[UF.root(A)];
            ll B_siz = siz[UF.root(B)];
            ans.pb((A_siz )*(B_siz));
//            cerr << "Asize: " << A_siz << "  Bsize:" << B_siz << endl;
            UF.unite(A,B);
            
            siz[UF.root(A)] =  A_siz + B_siz;
        }else{
            ans.pb(0);
        }
        

    }
    
    ll now = 0;
    cerr << "----" << endl;
    rep(i, ans.size()){
        now += ans[ans.size()-1-i];
        cout << now << endl;
    }

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 11376