N,M=list(map(int,input().split()))
edge=[list(map(int,input().split())) for _ in range(M)]

current=N*(N-1)//2
ret=[0]*M

par=list(range(N+1))
cnt=[1]*(N+1)
rank=[0]*(N+1)

def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def same(x,y):
    return find(x)==find(y)

def size(x):
    return cnt[find(x)]

def unite(x,y):
    x=find(x)
    y=find(y)

    if x==y:
        return 0
    
    if rank[x]<rank[y]:
        cnt[y]+=size(x)
        par[x]=y
    else:
        cnt[x]+=size(y)
        par[y]=x
        if rank[x]==rank[y]:rank[x]+=1


for i in range(M-1,-1,-1):
    ret[i]=current

    a,b=edge[i]

    if not same(a,b):
        current-=size(a)*size(b)
        unite(a,b)

for r in ret:
    print(r) N,M=list(map(int,input().split())) N list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split M list(map(int,input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split edge=[list(map(int,input().split())) for _ in range(M)] edge [list(map(int,input().split())) for _ in range(M)] current=N*(N-1)//2 current N*(N-1)//2 N*(N-1) N N-1 N 1 2 ret=[0]*M ret [0]*M [0] 0 M par=list(range(N+1)) par list(range(N+1)) list range(N+1) range N+1 N 1 cnt=[1]*(N+1) cnt [1]*(N+1) [1] 1 N+1 N 1 rank=[0]*(N+1) rank [0]*(N+1) [0] 0 N+1 N 1 def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x] find if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x] x==par[x] x par[x] par x 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 same(x,y):
    return find(x)==find(y) 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 cnt[find(x)] size return cnt[find(x)] cnt[find(x)] cnt find(x) find x x x def unite(x,y):
    x=find(x)
    y=find(y)

    if x==y:
        return 0
    
    if rank[x]<rank[y]:
        cnt[y]+=size(x)
        par[x]=y
    else:
        cnt[x]+=size(y)
        par[y]=x
        if rank[x]==rank[y]:rank[x]+=1 unite x=find(x) x find(x) find x y=find(y) y find(y) find y if x==y:
        return 0
    
     x==y x y return 0 0 if rank[x]<rank[y]:
        cnt[y]+=size(x)
        par[x]=y
    else:
        cnt[x]+=size(y)
        par[y]=x
        if rank[x]==rank[y]:rank[x]+=1 rank[x]<rank[y] rank[x] rank x rank[y] rank y cnt[y]+=size(x) cnt[y] cnt y size(x) size x par[x]=y par[x] par x y cnt[x]+=size(y) cnt[x] cnt x size(y) size y par[y]=x par[y] par y x if rank[x]==rank[y]:ra rank[x]==rank[y] rank[x] rank x rank[y] rank y x x y y for i in range(M-1,-1,-1):
    ret[i]=current

    a,b=edge[i]

    if not same(a,b):
        current-=size(a)*size(b)
        unite(a,b) i range(M-1,-1,-1) range M-1 M 1 -1 -1 ret[i]=current ret[i] ret i current a,b=edge[i] a edge[i] edge i b if not same(a,b):
        current-=size(a)*size(b)
        unite(a,b) not same(a,b) same(a,b) same a b current-=size(a)*size(b) current size(a)*size(b) size(a) size a size(b) size b unite(a,b) unite a b for r in ret:
    print(r) r ret print(r) print r def unite(x,y):
    x=find(x)
    y=find(y)

    if x==y:
        return 0
    
    if rank[x]<rank[y]:
        cnt[y]+=size(x)
        par[x]=y
    else:
        cnt[x]+=size(y)
        par[y]=x
        if rank[x]==rank[y]:rank[x]+=1 def unite(x,y):
    x=find(x)
    y=find(y)

    if x==y:
        return 0
    
    if rank[x]<rank[y]:
        cnt[y]+=size(x)
        par[x]=y
    else:
        cnt[x]+=size(y)
        par[y]=x
        if rank[x]==rank[y]:rank[x]+=1 unite current-=size(a)*size(b) size(a)*size(b) current current=N*(N-1)//2 N*(N-1)//2 current cnt=[1]*(N+1) [1]*(N+1) cnt ret=[0]*M [0]*M ret N,M=list(map(int,input().split())) list(map(int,input().split())) N rank=[0]*(N+1) [0]*(N+1) rank def same(x,y):
    return find(x)==find(y) def same(x,y):
    return find(x)==find(y) same M=list(map(int,input().split())) list(map(int,input().split())) M def size(x):
    return cnt[find(x)] def size(x):
    return cnt[find(x)] size a,b=edge[i] edge[i] a edge=[list(map(int,input().split())) for _ in range(M)] [list(map(int,input().split())) for _ in range(M)] edge par=list(range(N+1)) list(range(N+1)) par b=edge[i] edge[i] b def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x] def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x] find
N,M=list(map(int,input().split()))
edge=[list(map(int,input().split())) for _ in range(M)]

current=N*(N-1)//2
ret=[0]*M

par=list(range(N+1))
cnt=[1]*(N+1)
rank=[0]*(N+1)

def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def same(x,y):
    return find(x)==find(y)

def size(x):
    return cnt[find(x)]

def unite(x,y):
    x=find(x)
    y=find(y)

    if x==y:
        return 0
    
    if rank[x]<rank[y]:
        cnt[y]+=size(x)
        par[x]=y
    else:
        cnt[x]+=size(y)
        par[y]=x
        if rank[x]==rank[y]:rank[x]+=1


for i in range(M-1,-1,-1):
    ret[i]=current

    a,b=edge[i]

    if not same(a,b):
        current-=size(a)*size(b)
        unite(a,b)

for r in ret:
    print(r)