#include<bits/stdc++.h>

#define mx 100005

using namespace std;

long long n, m, a[mx], b[mx], ans[mx], p[mx], nm[mx];

void ufini(int n){
  for(int i = 1; i <= n; i++) p[i] = i;
  fill(nm+1, nm+n+1, 1);
}

int find(int x){return (x == p[x] ? x : p[x] = find(p[x]));}

long long uni(int x, int y){
  if(find(x) != find(y)){
    long long tx = nm[p[x]], ty = nm[p[y]];
    nm[p[x]] += nm[p[y]];
    p[p[y]] = p[x];
    return (tx+ty)*(tx+ty-1)/2 - tx*(tx-1)/2 - ty*(ty-1)/2;
  }else return 0;
}

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; i++) scanf("%d%d", a+i, b+i);
  ans[m-1] = n*(n-1)/2;
  ufini(n);
  for(int i = m-1; i > 0; i--) ans[i-1] = ans[i] - uni(a[i], b[i]);
  for(int i = 0; i < m; i++) printf("%lld\n", ans[i]);
}