class Unionfind:
    def __init__(self,n):
        self.par=[x for x in range(n)]
        self.rank=[1]*n
        self.num=[1]*n

    def root(self,a):
        if self.par[a]==a : return a
        parent=self.root(self.par[a])
        self.par[a]=parent
        return parent

    def unite(self,a,b):
        ra,rb=self.root(a),self.root(b)
        out=self.num[ra]*self.num[rb]
        if self.rank[ra]<self.rank[rb]:
            ra,rb=rb,ra
        self.par[rb]=ra
        self.num[ra]+=self.num[rb]
        if self.rank[ra]==self.rank[rb]:
            self.rank[ra]+=1
        return out
        
    def same(self,a,b):
        return self.root(a)==self.root(b)

    def com_num(self,a,b):
        if self.same(a,b): return 0
        else : return self.unite(a,b)
        

def main():
    n,m=map(int,input().split())
    incon=[0]*(m+1)
    bridge=[0]*m
    uf=Unionfind(n)
    for i in range(m):
        a,b=map(int,input().split())
        bridge[i]=(a-1,b-1)
    incon[m]=n*(n-1)//2

    for i in range(m-1,-1,-1):
        a,b=bridge[i]
        incon[i]=incon[i+1]-uf.com_num(a,b)

    for i in range(1,m+1):
        print(incon[i])

main() class Unionfind:
    def __init__(self,n):
        self.par=[x for x in range(n)]
        self.rank=[1]*n
        self.num=[1]*n

    def root(self,a):
        if self.par[a]==a : return a
        parent=self.root(self.par[a])
        self.par[a]=parent
        return parent

    def unite(self,a,b):
        ra,rb=self.root(a),self.root(b)
        out=self.num[ra]*self.num[rb]
        if self.rank[ra]<self.rank[rb]:
            ra,rb=rb,ra
        self.par[rb]=ra
        self.num[ra]+=self.num[rb]
        if self.rank[ra]==self.rank[rb]:
            self.rank[ra]+=1
        return out
        
    def same(self,a,b):
        return self.root(a)==self.root(b)

    def com_num(self,a,b):
        if self.same(a,b): return 0
        else : return self.unite(a,b)
         Unionfind def __init__(self,n):
        self.par=[x for x in range(n)]
        self.rank=[1]*n
        self.num=[1]*n

     __init__ x for x in range(n) for x in range(n) x range(n) range n for x in range(n) x self.par=[x for x in range(n)] self.par self par [x for x in range(n)] self.rank=[1]*n self.rank self rank [1]*n [1] 1 n self.num=[1]*n self.num self num [1]*n [1] 1 n self self n n def root(self,a):
        if self.par[a]==a : return a
        parent=self.root(self.par[a])
        self.par[a]=parent
        return parent

     root if self.par[a]==a : return a
         self.par[a]==a self.par[a] self.par self par a a parent=self.root(self.par[a]) parent self.root(self.par[a]) self.root self root self.par[a] self.par self par a self.par[a]=parent self.par[a] self.par self par a parent return parent parent self self a a def unite(self,a,b):
        ra,rb=self.root(a),self.root(b)
        out=self.num[ra]*self.num[rb]
        if self.rank[ra]<self.rank[rb]:
            ra,rb=rb,ra
        self.par[rb]=ra
        self.num[ra]+=self.num[rb]
        if self.rank[ra]==self.rank[rb]:
            self.rank[ra]+=1
        return out
        
     unite ra,rb=self.root(a),self.root(b) ra self.root(a) self.root self root a rb self.root(b) self.root self root b out=self.num[ra]*self.num[rb] out self.num[ra]*self.num[rb] self.num[ra] self.num self num ra self.num[rb] self.num self num rb if self.rank[ra]<self.rank[rb]:
            ra,rb=rb,ra
         self.rank[ra]<self.rank[rb] self.rank[ra] self.rank self rank ra self.rank[rb] self.rank self rank rb ra,rb=rb,ra ra rb rb ra self.par[rb]=ra self.par[rb] self.par self par rb ra self.num[ra]+=self.num[rb] self.num[ra] self.num self num ra self.num[rb] self.num self num rb if self.rank[ra]==self.rank[rb]:
            self.rank[ra]+=1
         self.rank[ra]==self.rank[rb] self.rank[ra] self.rank self rank ra self.rank[rb] self.rank self rank rb self.rank[ra]+=1 self.rank[ra] self.rank self rank ra 1 return out out self self a a b b def same(self,a,b):
        return self.root(a)==self.root(b)

     same return self.root(a)==self.root(b) self.root(a)==self.root(b) self.root(a) self.root self root a self.root(b) self.root self root b self self a a b b def com_num(self,a,b):
        if self.same(a,b): return 0
        else : return self.unite(a,b)
         com_num if self.same(a,b): return 0
        else : return self.unite(a,b)
         self.same(a,b) self.same self same a b self self a a b b def main():
    n,m=map(int,input().split())
    incon=[0]*(m+1)
    bridge=[0]*m
    uf=Unionfind(n)
    for i in range(m):
        a,b=map(int,input().split())
        bridge[i]=(a-1,b-1)
    incon[m]=n*(n-1)//2

    for i in range(m-1,-1,-1):
        a,b=bridge[i]
        incon[i]=incon[i+1]-uf.com_num(a,b)

    for i in range(1,m+1):
        print(incon[i]) main n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m incon=[0]*(m+1) incon [0]*(m+1) [0] 0 m+1 m 1 bridge=[0]*m bridge [0]*m [0] 0 m uf=Unionfind(n) uf Unionfind(n) Unionfind n for i in range(m):
        a,b=map(int,input().split())
        bridge[i]=(a-1,b-1)
     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[i]=(a-1,b-1) bridge[i] bridge i (a-1,b-1) a-1 a 1 b-1 b 1 incon[m]=n*(n-1)//2 incon[m] incon m n*(n-1)//2 n*(n-1) n n-1 n 1 2 for i in range(m-1,-1,-1):
        a,b=bridge[i]
        incon[i]=incon[i+1]-uf.com_num(a,b)

     i range(m-1,-1,-1) range m-1 m 1 -1 -1 a,b=bridge[i] a bridge[i] bridge i b incon[i]=incon[i+1]-uf.com_num(a,b) incon[i] incon i incon[i+1]-uf.com_num(a,b) incon[i+1] incon i+1 i 1 uf.com_num(a,b) uf.com_num uf com_num a b for i in range(1,m+1):
        print(incon[i]) i range(1,m+1) range 1 m+1 m 1 print(incon[i]) print incon[i] incon i main() main class Unionfind:
    def __init__(self,n):
        self.par=[x for x in range(n)]
        self.rank=[1]*n
        self.num=[1]*n

    def root(self,a):
        if self.par[a]==a : return a
        parent=self.root(self.par[a])
        self.par[a]=parent
        return parent

    def unite(self,a,b):
        ra,rb=self.root(a),self.root(b)
        out=self.num[ra]*self.num[rb]
        if self.rank[ra]<self.rank[rb]:
            ra,rb=rb,ra
        self.par[rb]=ra
        self.num[ra]+=self.num[rb]
        if self.rank[ra]==self.rank[rb]:
            self.rank[ra]+=1
        return out
        
    def same(self,a,b):
        return self.root(a)==self.root(b)

    def com_num(self,a,b):
        if self.same(a,b): return 0
        else : return self.unite(a,b)
         class Unionfind:
    def __init__(self,n):
        self.par=[x for x in range(n)]
        self.rank=[1]*n
        self.num=[1]*n

    def root(self,a):
        if self.par[a]==a : return a
        parent=self.root(self.par[a])
        self.par[a]=parent
        return parent

    def unite(self,a,b):
        ra,rb=self.root(a),self.root(b)
        out=self.num[ra]*self.num[rb]
        if self.rank[ra]<self.rank[rb]:
            ra,rb=rb,ra
        self.par[rb]=ra
        self.num[ra]+=self.num[rb]
        if self.rank[ra]==self.rank[rb]:
            self.rank[ra]+=1
        return out
        
    def same(self,a,b):
        return self.root(a)==self.root(b)

    def com_num(self,a,b):
        if self.same(a,b): return 0
        else : return self.unite(a,b)
         Unionfind def main():
    n,m=map(int,input().split())
    incon=[0]*(m+1)
    bridge=[0]*m
    uf=Unionfind(n)
    for i in range(m):
        a,b=map(int,input().split())
        bridge[i]=(a-1,b-1)
    incon[m]=n*(n-1)//2

    for i in range(m-1,-1,-1):
        a,b=bridge[i]
        incon[i]=incon[i+1]-uf.com_num(a,b)

    for i in range(1,m+1):
        print(incon[i]) def main():
    n,m=map(int,input().split())
    incon=[0]*(m+1)
    bridge=[0]*m
    uf=Unionfind(n)
    for i in range(m):
        a,b=map(int,input().split())
        bridge[i]=(a-1,b-1)
    incon[m]=n*(n-1)//2

    for i in range(m-1,-1,-1):
        a,b=bridge[i]
        incon[i]=incon[i+1]-uf.com_num(a,b)

    for i in range(1,m+1):
        print(incon[i]) main
class Unionfind:
    def __init__(self,n):
        self.par=[x for x in range(n)]
        self.rank=[1]*n
        self.num=[1]*n

    def root(self,a):
        if self.par[a]==a : return a
        parent=self.root(self.par[a])
        self.par[a]=parent
        return parent

    def unite(self,a,b):
        ra,rb=self.root(a),self.root(b)
        out=self.num[ra]*self.num[rb]
        if self.rank[ra]<self.rank[rb]:
            ra,rb=rb,ra
        self.par[rb]=ra
        self.num[ra]+=self.num[rb]
        if self.rank[ra]==self.rank[rb]:
            self.rank[ra]+=1
        return out
        
    def same(self,a,b):
        return self.root(a)==self.root(b)

    def com_num(self,a,b):
        if self.same(a,b): return 0
        else : return self.unite(a,b)
        

def main():
    n,m=map(int,input().split())
    incon=[0]*(m+1)
    bridge=[0]*m
    uf=Unionfind(n)
    for i in range(m):
        a,b=map(int,input().split())
        bridge[i]=(a-1,b-1)
    incon[m]=n*(n-1)//2

    for i in range(m-1,-1,-1):
        a,b=bridge[i]
        incon[i]=incon[i+1]-uf.com_num(a,b)

    for i in range(1,m+1):
        print(incon[i])

main()