N,M=map(int,input().split())
bridge=[]
size=[1]*(N+1)
tree=list(range(N+1))
def find(a):
    x=tree[a]
    if a==x:
        return a
    x=find(x)
    tree[a]=x
    return x
for i in range(M):
    A,B=map(int,input().split())
    bridge.append((A,B))
Ans=N*(N-1)//2
ans=[]
for a,b in bridge[::-1]:
    aroot=find(a)
    broot=find(b)
    if aroot==broot:
        ans.append(Ans)
        continue
    ans.append(Ans)
    sa=size[aroot]
    sb=size[broot]
    Ans-=sa*sb
    if sa>sb:
        tree[broot]=aroot
        size[aroot]+=sb
    else:
        tree[aroot]=broot
        size[broot]+=sa
for i in ans[::-1]:
    print(i) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M bridge=[] bridge [] size=[1]*(N+1) size [1]*(N+1) [1] 1 N+1 N 1 tree=list(range(N+1)) tree list(range(N+1)) list range(N+1) range N+1 N 1 def find(a):
    x=tree[a]
    if a==x:
        return a
    x=find(x)
    tree[a]=x
    return x find x=tree[a] x tree[a] tree a if a==x:
        return a
     a==x a x return a a x=find(x) x find(x) find x tree[a]=x tree[a] tree a x return x x a a for i in range(M):
    A,B=map(int,input().split())
    bridge.append((A,B)) i range(M) range M A,B=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B bridge.append((A,B)) bridge.append bridge append (A,B) A B Ans=N*(N-1)//2 Ans N*(N-1)//2 N*(N-1) N N-1 N 1 2 ans=[] ans [] for a,b in bridge[::-1]:
    aroot=find(a)
    broot=find(b)
    if aroot==broot:
        ans.append(Ans)
        continue
    ans.append(Ans)
    sa=size[aroot]
    sb=size[broot]
    Ans-=sa*sb
    if sa>sb:
        tree[broot]=aroot
        size[aroot]+=sb
    else:
        tree[aroot]=broot
        size[broot]+=sa a b bridge[::-1] bridge ::-1 -1 aroot=find(a) aroot find(a) find a broot=find(b) broot find(b) find b if aroot==broot:
        ans.append(Ans)
        continue
     aroot==broot aroot broot ans.append(Ans) ans.append ans append Ans continue ans.append(Ans) ans.append ans append Ans sa=size[aroot] sa size[aroot] size aroot sb=size[broot] sb size[broot] size broot Ans-=sa*sb Ans sa*sb sa sb if sa>sb:
        tree[broot]=aroot
        size[aroot]+=sb
    else:
        tree[aroot]=broot
        size[broot]+=sa sa>sb sa sb tree[broot]=aroot tree[broot] tree broot aroot size[aroot]+=sb size[aroot] size aroot sb tree[aroot]=broot tree[aroot] tree aroot broot size[broot]+=sa size[broot] size broot sa for i in ans[::-1]:
    print(i) i ans[::-1] ans ::-1 -1 print(i) print i broot=find(b) find(b) broot A,B=map(int,input().split()) map(int,input().split()) A Ans=N*(N-1)//2 N*(N-1)//2 Ans sa=size[aroot] size[aroot] sa N,M=map(int,input().split()) map(int,input().split()) N Ans-=sa*sb sa*sb Ans def find(a):
    x=tree[a]
    if a==x:
        return a
    x=find(x)
    tree[a]=x
    return x def find(a):
    x=tree[a]
    if a==x:
        return a
    x=find(x)
    tree[a]=x
    return x find ans=[] [] ans sb=size[broot] size[broot] sb aroot=find(a) find(a) aroot tree=list(range(N+1)) list(range(N+1)) tree size=[1]*(N+1) [1]*(N+1) size M=map(int,input().split()) map(int,input().split()) M bridge=[] [] bridge B=map(int,input().split()) map(int,input().split()) B
N,M=map(int,input().split())
bridge=[]
size=[1]*(N+1)
tree=list(range(N+1))
def find(a):
    x=tree[a]
    if a==x:
        return a
    x=find(x)
    tree[a]=x
    return x
for i in range(M):
    A,B=map(int,input().split())
    bridge.append((A,B))
Ans=N*(N-1)//2
ans=[]
for a,b in bridge[::-1]:
    aroot=find(a)
    broot=find(b)
    if aroot==broot:
        ans.append(Ans)
        continue
    ans.append(Ans)
    sa=size[aroot]
    sb=size[broot]
    Ans-=sa*sb
    if sa>sb:
        tree[broot]=aroot
        size[aroot]+=sb
    else:
        tree[aroot]=broot
        size[broot]+=sa
for i in ans[::-1]:
    print(i)