r=lambda x:x if u[x]<0else r(u[x])

(n,m),_,*e=[map(int,t.split())for t in open(0).readlines()]

u=[-1]*-~n

a=[n*~-n//2]

for x,y in e[::-1]:

 t=a[-1];x,y=sorted((r(x),r(y)))

 if x!=y:t-=u[x]*u[y];u[x]+=u[y];u[y]=x

 a+=[t]

print(*a[::-1],sep='\n')

r=lambda x:x if u[x]<0else r(u[x])

(n,m),_,*e=[map(int,t.split())for t in open(0).readlines()]

u=[-1]*-~n

t=n*~-n//2

a=[t]

for x,y in e[::-1]:

 x,y=sorted((r(x),r(y)))

 if x!=y:t-=u[x]*u[y];u[x]+=u[y];u[y]=x

 a+=[t]

print(*a[::-1],sep='\n')

r = lambda x: x if u[x] < 0 else r(u[x])
(n, m), _, *e = [map(int, t.split()) for t in open(0).readlines()]
u = [-1] * -~n
a = [n * ~-n // 2]
for x, y in e[::-1]:
    t = a[-1]
    x, y = sorted((r(x), r(y)))
    if x != y:
        t -= u[x] * u[y]
        u[x] += u[y]
        u[y] = x
    a += [t]
print(*a[::-1], sep="\n")

r = lambda x: x if u[x] < 0 else r(u[x])
(n, m), _, *e = [map(int, t.split()) for t in open(0).readlines()]
u = [-1] * -~n
t = n * ~-n // 2
a = [t]
for x, y in e[::-1]:
    x, y = sorted((r(x), r(y)))
    if x != y:
        t -= u[x] * u[y]
        u[x] += u[y]
        u[y] = x
    a += [t]
print(*a[::-1], sep="\n")

-a = [n * ~-n // 2] +t = n * ~-n // 2 +a = [t] -    t = a[-1]