#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"r=lambda x:x if u[x]<0else r(u[x])\n"
"n,m,*e=map(int,open(0).read().split())\n"
"u=[-1]*-~n\n"
"t=n*~-n//2\n"
"a=[t]\n"
"for x,y in zip(e[-2:1:-2],e[:1:-2]):\n"
" x,y=sorted((r(x),r(y)))\n"
" if x!=y:t-=u[x]*u[y];u[x]+=u[y];u[y]=x\n"
" a+=[t]\n"
"print(*a[::-1],sep='\n')\n"
"\"";
  system(s);
  return 0;
}            