import sys
sys.setrecursionlimit(100000)

n, m=map(int, input().split())
a=[0 for i in range(m)]
b=[0 for i in range(m)]
g=[list() for i in range(1+n)]
#print(g)

par=[i for i in range(n)]
cnt_con=[1 for i in range(n)]

def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x]
def connect(x,y):
    #par[x]=root(x)
    #par[y]=root(y)
    if root(x)==root(y):
        0
    else:
        cnt_con[root(y)]+=cnt_con[root(x)]
        par[root(x)]=root(y)      
    return

for i in range(m):
    a[i], b[i]=map(int, input().split())
    a[i], b[i]=a[i]-1, b[i]-1


tmp=int(n*(n-1)/2)
ans=[0]*m
ans[-1]=tmp
#ans[0]=0
#print('a,b=',a,b)
for i in range(m-1,-1,-1):
    ans[i]=tmp
    if root(a[i])==root(b[i]):
        0
    else:
        tmp-=cnt_con[root(a[i])]*cnt_con[root(b[i])]
    connect(a[i],b[i])
    #print('i,tmp',i,(a[i],b[i]),ans[i],tmp,par,cnt_con)
    

    
for i in range(m):
    print(ans[i])
 import sys sys sys.setrecursionlimit(100000) sys.setrecursionlimit sys setrecursionlimit 100000 n, m=map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 a=[0 for i in range(m)] a [0 for i in range(m)] 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 b=[0 for i in range(m)] b [0 for i in range(m)] list() for i in range(1+n) for i in range(1+n) i range(1+n) range 1+n 1 n for i in range(1+n) list() list g=[list() for i in range(1+n)] g [list() for i in range(1+n)] i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i par=[i for i in range(n)] par [i for i in range(n)] 1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 1 cnt_con=[1 for i in range(n)] cnt_con [1 for i in range(n)] def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x] root if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x] x==par[x] x par[x] par x return x x par[x]=root(par[x]) par[x] par x root(par[x]) root par[x] par x return par[x] par[x] par x x x def connect(x,y):
    #par[x]=root(x)
    #par[y]=root(y)
    if root(x)==root(y):
        0
    else:
        cnt_con[root(y)]+=cnt_con[root(x)]
        par[root(x)]=root(y)      
    return connect if root(x)==root(y):
        0
    else:
        cnt_con[root(y)]+=cnt_con[root(x)]
        par[root(x)]=root(y)      
     root(x)==root(y) root(x) root x root(y) root y 0 cnt_con[root(y)]+=cnt_con[root(x)] cnt_con[root(y)] cnt_con root(y) root y cnt_con[root(x)] cnt_con root(x) root x par[root(x)]=root(y) par[root(x)] par root(x) root x root(y) root y return x x y y for i in range(m):
    a[i], b[i]=map(int, input().split())
    a[i], b[i]=a[i]-1, b[i]-1 i range(m) range m a[i], b[i]=map(int, input().split()) a[i] a i map(int, input().split()) map int input().split() ().split () input split b[i] b i a[i], b[i]=a[i]-1, b[i]-1 a[i] a i a[i]-1 a[i] a i 1 b[i] b i b[i]-1 b[i] b i 1 tmp=int(n*(n-1)/2) tmp int(n*(n-1)/2) int n*(n-1)/2 n*(n-1) n n-1 n 1 2 ans=[0]*m ans [0]*m [0] 0 m ans[-1]=tmp ans[-1] ans -1 tmp for i in range(m-1,-1,-1):
    ans[i]=tmp
    if root(a[i])==root(b[i]):
        0
    else:
        tmp-=cnt_con[root(a[i])]*cnt_con[root(b[i])]
    connect(a[i],b[i])
    #print('i,tmp',i,(a[i],b[i]),ans[i],tmp,par,cnt_con)
    

     i range(m-1,-1,-1) range m-1 m 1 -1 -1 ans[i]=tmp ans[i] ans i tmp if root(a[i])==root(b[i]):
        0
    else:
        tmp-=cnt_con[root(a[i])]*cnt_con[root(b[i])]
     root(a[i])==root(b[i]) root(a[i]) root a[i] a i root(b[i]) root b[i] b i 0 tmp-=cnt_con[root(a[i])]*cnt_con[root(b[i])] tmp cnt_con[root(a[i])]*cnt_con[root(b[i])] cnt_con[root(a[i])] cnt_con root(a[i]) root a[i] a i cnt_con[root(b[i])] cnt_con root(b[i]) root b[i] b i connect(a[i],b[i]) connect a[i] a i b[i] b i for i in range(m):
    print(ans[i]) i range(m) range m print(ans[i]) print ans[i] ans i g=[list() for i in range(1+n)] [list() for i in range(1+n)] g def connect(x,y):
    #par[x]=root(x)
    #par[y]=root(y)
    if root(x)==root(y):
        0
    else:
        cnt_con[root(y)]+=cnt_con[root(x)]
        par[root(x)]=root(y)      
    return def connect(x,y):
    #par[x]=root(x)
    #par[y]=root(y)
    if root(x)==root(y):
        0
    else:
        cnt_con[root(y)]+=cnt_con[root(x)]
        par[root(x)]=root(y)      
    return connect tmp-=cnt_con[root(a[i])]*cnt_con[root(b[i])] cnt_con[root(a[i])]*cnt_con[root(b[i])] tmp n, m=map(int, input().split()) map(int, input().split()) n b=[0 for i in range(m)] [0 for i in range(m)] b m=map(int, input().split()) map(int, input().split()) m cnt_con=[1 for i in range(n)] [1 for i in range(n)] cnt_con tmp=int(n*(n-1)/2) int(n*(n-1)/2) tmp par=[i for i in range(n)] [i for i in range(n)] par ans=[0]*m [0]*m ans def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x] def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x] root a=[0 for i in range(m)] [0 for i in range(m)] a
import sys
sys.setrecursionlimit(100000)

n, m=map(int, input().split())
a=[0 for i in range(m)]
b=[0 for i in range(m)]
g=[list() for i in range(1+n)]
#print(g)

par=[i for i in range(n)]
cnt_con=[1 for i in range(n)]

def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x]
def connect(x,y):
    #par[x]=root(x)
    #par[y]=root(y)
    if root(x)==root(y):
        0
    else:
        cnt_con[root(y)]+=cnt_con[root(x)]
        par[root(x)]=root(y)      
    return

for i in range(m):
    a[i], b[i]=map(int, input().split())
    a[i], b[i]=a[i]-1, b[i]-1


tmp=int(n*(n-1)/2)
ans=[0]*m
ans[-1]=tmp
#ans[0]=0
#print('a,b=',a,b)
for i in range(m-1,-1,-1):
    ans[i]=tmp
    if root(a[i])==root(b[i]):
        0
    else:
        tmp-=cnt_con[root(a[i])]*cnt_con[root(b[i])]
    connect(a[i],b[i])
    #print('i,tmp',i,(a[i],b[i]),ans[i],tmp,par,cnt_con)
    

    
for i in range(m):
    print(ans[i])

