import sys
input = sys.stdin.readline
from collections import deque
n,m = [int(i) for i in input().split()]
ab = deque([])
for i in range(m):
  a,b = [int(i) for i in input().split()]
  ab_appendleft = ab.appendleft
  ab_appendleft((a-1,b-1))
  
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]
  
par = [-1]*n
ans = n*(n-1)//2
chk = deque([])
chk_appendleft = chk.appendleft
chk_appendleft(n*(n-1)//2)

for i in ab:
  if not same(i[0],i[1]):
    c = size(i[0])
    d = size(i[1])
    unite(i[0],i[1])
    ans -= c*d
    chk_appendleft(ans)
  else:
    chk_appendleft(ans)

chk = list(chk)[1:]
for i in chk:
  print(i) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline from collections import deque int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i n,m = [int(i) for i in input().split()] n [int(i) for i in input().split()] m ab = deque([]) ab deque([]) deque [] for i in range(m):
  a,b = [int(i) for i in input().split()]
  ab_appendleft = ab.appendleft
  ab_appendleft((a-1,b-1))
  
#xの根を求める i range(m) range m int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i a,b = [int(i) for i in input().split()] a [int(i) for i in input().split()] b ab_appendleft = ab.appendleft ab_appendleft ab.appendleft ab appendleft ab_appendleft((a-1,b-1)) ab_appendleft (a-1,b-1) a-1 a 1 b-1 b 1 def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合 find if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合 par[x] < 0 par[x] par x 0 return x x par[x] = find(par[x]) par[x] par x find(par[x]) find par[x] par x return par[x] par[x] par x x x def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定 unite x = find(x) x find(x) find x y = find(y) y find(y) find y if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定 x == y x y return False False if par[x] > par[y]:
            x,y = y,x
         par[x] > par[y] par[x] par x par[y] par y x,y = y,x x y y x par[x] += par[y] par[x] par x par[y] par y par[y] = x par[y] par y x return True True x x y y def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数 same return find(x) == find(y) find(x) == find(y) find(x) find x find(y) find y x x y y def size(x):
    return -par[find(x)]
   size return -par[find(x)] -par[find(x)] par[find(x)] par find(x) find x x x par = [-1]*n par [-1]*n [-1] -1 n ans = n*(n-1)//2 ans n*(n-1)//2 n*(n-1) n n-1 n 1 2 chk = deque([]) chk deque([]) deque [] chk_appendleft = chk.appendleft chk_appendleft chk.appendleft chk appendleft chk_appendleft(n*(n-1)//2) chk_appendleft n*(n-1)//2 n*(n-1) n n-1 n 1 2 for i in ab:
  if not same(i[0],i[1]):
    c = size(i[0])
    d = size(i[1])
    unite(i[0],i[1])
    ans -= c*d
    chk_appendleft(ans)
  else:
    chk_appendleft(ans) i ab if not same(i[0],i[1]):
    c = size(i[0])
    d = size(i[1])
    unite(i[0],i[1])
    ans -= c*d
    chk_appendleft(ans)
  else:
    chk_appendleft(ans) not same(i[0],i[1]) same(i[0],i[1]) same i[0] i 0 i[1] i 1 c = size(i[0]) c size(i[0]) size i[0] i 0 d = size(i[1]) d size(i[1]) size i[1] i 1 unite(i[0],i[1]) unite i[0] i 0 i[1] i 1 ans -= c*d ans c*d c d chk_appendleft(ans) chk_appendleft ans chk_appendleft(ans) chk_appendleft ans chk = list(chk)[1:] chk list(chk)[1:] (chk) list chk 1: 1 for i in chk:
  print(i) i chk print(i) print i chk = deque([]) deque([]) chk m = [int(i) for i in input().split()] [int(i) for i in input().split()] m chk_appendleft = chk.appendleft chk.appendleft chk_appendleft input = sys.stdin.readline sys.stdin.readline input ans = n*(n-1)//2 n*(n-1)//2 ans ab_appendleft = ab.appendleft ab.appendleft ab_appendleft chk = list(chk)[1:] list(chk)[1:] chk d = size(i[1]) size(i[1]) d ab = deque([]) deque([]) ab def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定 def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定 unite def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数 def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数 same a,b = [int(i) for i in input().split()] [int(i) for i in input().split()] a b = [int(i) for i in input().split()] [int(i) for i in input().split()] b par = [-1]*n [-1]*n par def size(x):
    return -par[find(x)]
   def size(x):
    return -par[find(x)]
   size c = size(i[0]) size(i[0]) c def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合 def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合 find n,m = [int(i) for i in input().split()] [int(i) for i in input().split()] n ans -= c*d c*d ans
import sys
input = sys.stdin.readline
from collections import deque
n,m = [int(i) for i in input().split()]
ab = deque([])
for i in range(m):
  a,b = [int(i) for i in input().split()]
  ab_appendleft = ab.appendleft
  ab_appendleft((a-1,b-1))
  
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]
  
par = [-1]*n
ans = n*(n-1)//2
chk = deque([])
chk_appendleft = chk.appendleft
chk_appendleft(n*(n-1)//2)

for i in ab:
  if not same(i[0],i[1]):
    c = size(i[0])
    d = size(i[1])
    unite(i[0],i[1])
    ans -= c*d
    chk_appendleft(ans)
  else:
    chk_appendleft(ans)

chk = list(chk)[1:]
for i in chk:
  print(i)