N,M=map(int,input().split())

#Union-Find

par=[i for i in range(N)]
siz=[1 for _ in range(N)]
rank=[0 for _ in range(N)]
root=set()

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

def union(a,b):
    a=find(a)
    b=find(b)
    if(a==b):
        return 0
    else:
        if rank[a]>rank[b]:
            par[b]=a
            if b in root:
                root.remove(b)
            root.add(a)
            siz[a]+=siz[b]
        else:
            par[a]=b
            if a in root:
                root.remove(a)
            root.add(b)
            siz[b]+=siz[a]
            if rank[a]==rank[b]:
                rank[b]+=1
def size(a):
    return siz[find(a)]

def same(a,b):
    return find(a)==find(b)
    
edge=[]
for i in range(M):
    a,b=map(lambda x:int(x)-1,input().split())
    edge.append([a,b])
p=N*(N-1)//2
res=[p]
for i in reversed(range(1,M)):
    if(not same(edge[i][0],edge[i][1])):
        p=p-size(edge[i][0])*size(edge[i][1])
        union(edge[i][0],edge[i][1])
    res.append(p)
print(*res[::-1],sep='\n') N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M 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 _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 1 siz=[1 for _ in range(N)] siz [1 for _ in range(N)] 0 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 0 rank=[0 for _ in range(N)] rank [0 for _ in range(N)] root=set() root set() set def find(x):
    if(par[x]==x):
        return x
    else:
        par[x]=find(par[x])
        return par[x] find if(par[x]==x):
        return x
    else:
        par[x]=find(par[x])
        return par[x] par[x]==x par[x] par x 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 union(a,b):
    a=find(a)
    b=find(b)
    if(a==b):
        return 0
    else:
        if rank[a]>rank[b]:
            par[b]=a
            if b in root:
                root.remove(b)
            root.add(a)
            siz[a]+=siz[b]
        else:
            par[a]=b
            if a in root:
                root.remove(a)
            root.add(b)
            siz[b]+=siz[a]
            if rank[a]==rank[b]:
                rank[b]+=1 union a=find(a) a find(a) find a b=find(b) b find(b) find b if(a==b):
        return 0
    else:
        if rank[a]>rank[b]:
            par[b]=a
            if b in root:
                root.remove(b)
            root.add(a)
            siz[a]+=siz[b]
        else:
            par[a]=b
            if a in root:
                root.remove(a)
            root.add(b)
            siz[b]+=siz[a]
            if rank[a]==rank[b]:
                rank[b]+=1 a==b a b return 0 0 if rank[a]>rank[b]:
            par[b]=a
            if b in root:
                root.remove(b)
            root.add(a)
            siz[a]+=siz[b]
        else:
            par[a]=b
            if a in root:
                root.remove(a)
            root.add(b)
            siz[b]+=siz[a]
            if rank[a]==rank[b]:
                rank[b]+=1 rank[a]>rank[b] rank[a] rank a rank[b] rank b par[b]=a par[b] par b a if b in root:
                root.remove(b)
             b in root b root root.remove(b) root.remove root remove b root.add(a) root.add root add a siz[a]+=siz[b] siz[a] siz a siz[b] siz b par[a]=b par[a] par a b if a in root:
                root.remove(a)
             a in root a root root.remove(a) root.remove root remove a root.add(b) root.add root add b siz[b]+=siz[a] siz[b] siz b siz[a] siz a if rank[a]==rank[b]:
                rank[b]+=1 rank[a]==rank[b] rank[a] rank a rank[b] rank b rank[b]+=1 rank[b] rank b 1 a a b b def size(a):
    return siz[find(a)] size return siz[find(a)] siz[find(a)] siz find(a) find a a a def same(a,b):
    return find(a)==find(b)
     same return find(a)==find(b) find(a)==find(b) find(a) find a find(b) find b a a b b edge=[] edge [] for i in range(M):
    a,b=map(lambda x:int(x)-1,input().split())
    edge.append([a,b]) i range(M) range M a,b=map(lambda x:int(x)-1,input().split()) a map(lambda x:int(x)-1,input().split()) map lambda x:int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split b edge.append([a,b]) edge.append edge append [a,b] a b p=N*(N-1)//2 p N*(N-1)//2 N*(N-1) N N-1 N 1 2 res=[p] res [p] p for i in reversed(range(1,M)):
    if(not same(edge[i][0],edge[i][1])):
        p=p-size(edge[i][0])*size(edge[i][1])
        union(edge[i][0],edge[i][1])
    res.append(p) i reversed(range(1,M)) reversed range(1,M) range 1 M if(not same(edge[i][0],edge[i][1])):
        p=p-size(edge[i][0])*size(edge[i][1])
        union(edge[i][0],edge[i][1])
     not same(edge[i][0],edge[i][1]) same(edge[i][0],edge[i][1]) same edge[i][0] [i] edge i 0 edge[i][1] [i] edge i 1 p=p-size(edge[i][0])*size(edge[i][1]) p p-size(edge[i][0])*size(edge[i][1]) p size(edge[i][0])*size(edge[i][1]) size(edge[i][0]) size edge[i][0] [i] edge i 0 size(edge[i][1]) size edge[i][1] [i] edge i 1 union(edge[i][0],edge[i][1]) union edge[i][0] [i] edge i 0 edge[i][1] [i] edge i 1 res.append(p) res.append res append p print(*res[::-1],sep='\n') print *res[::-1] res[::-1] res ::-1 -1 sep='\n' sep '\n' p=N*(N-1)//2 N*(N-1)//2 p edge=[] [] edge M=map(int,input().split()) map(int,input().split()) M rank=[0 for _ in range(N)] [0 for _ in range(N)] rank def find(x):
    if(par[x]==x):
        return x
    else:
        par[x]=find(par[x])
        return par[x] def find(x):
    if(par[x]==x):
        return x
    else:
        par[x]=find(par[x])
        return par[x] find a,b=map(lambda x:int(x)-1,input().split()) map(lambda x:int(x)-1,input().split()) a def same(a,b):
    return find(a)==find(b)
     def same(a,b):
    return find(a)==find(b)
     same p=p-size(edge[i][0])*size(edge[i][1]) p-size(edge[i][0])*size(edge[i][1]) p siz=[1 for _ in range(N)] [1 for _ in range(N)] siz b=map(lambda x:int(x)-1,input().split()) map(lambda x:int(x)-1,input().split()) b N,M=map(int,input().split()) map(int,input().split()) N def union(a,b):
    a=find(a)
    b=find(b)
    if(a==b):
        return 0
    else:
        if rank[a]>rank[b]:
            par[b]=a
            if b in root:
                root.remove(b)
            root.add(a)
            siz[a]+=siz[b]
        else:
            par[a]=b
            if a in root:
                root.remove(a)
            root.add(b)
            siz[b]+=siz[a]
            if rank[a]==rank[b]:
                rank[b]+=1 def union(a,b):
    a=find(a)
    b=find(b)
    if(a==b):
        return 0
    else:
        if rank[a]>rank[b]:
            par[b]=a
            if b in root:
                root.remove(b)
            root.add(a)
            siz[a]+=siz[b]
        else:
            par[a]=b
            if a in root:
                root.remove(a)
            root.add(b)
            siz[b]+=siz[a]
            if rank[a]==rank[b]:
                rank[b]+=1 union par=[i for i in range(N)] [i for i in range(N)] par def size(a):
    return siz[find(a)] def size(a):
    return siz[find(a)] size res=[p] [p] res root=set() set() root
N,M=map(int,input().split())

#Union-Find

par=[i for i in range(N)]
siz=[1 for _ in range(N)]
rank=[0 for _ in range(N)]
root=set()

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

def union(a,b):
    a=find(a)
    b=find(b)
    if(a==b):
        return 0
    else:
        if rank[a]>rank[b]:
            par[b]=a
            if b in root:
                root.remove(b)
            root.add(a)
            siz[a]+=siz[b]
        else:
            par[a]=b
            if a in root:
                root.remove(a)
            root.add(b)
            siz[b]+=siz[a]
            if rank[a]==rank[b]:
                rank[b]+=1
def size(a):
    return siz[find(a)]

def same(a,b):
    return find(a)==find(b)
    
edge=[]
for i in range(M):
    a,b=map(lambda x:int(x)-1,input().split())
    edge.append([a,b])
p=N*(N-1)//2
res=[p]
for i in reversed(range(1,M)):
    if(not same(edge[i][0],edge[i][1])):
        p=p-size(edge[i][0])*size(edge[i][1])
        union(edge[i][0],edge[i][1])
    res.append(p)
print(*res[::-1],sep='\n')