class UnionFind:
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
        self.rank=[0]*n

    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return 

        if self.rank[x]<self.rank[y]:
            self.parents[y]+=self.parents[x]
            self.parents[x]=y
        else:
            self.parents[x]+=self.parents[y]
            self.parents[y]=x

            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def are_same(self,x,y):
        return self.find(x)==self.find(y)

    def element_count(self,x):
        x=self.find(x)
        return -self.parents[x]

    def group_count(self):
        count=0
        for e in self.parents:
            if e<0: count+=1
        return count

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    for i in range(m):
        a[i],b[i]=map(lambda x:int(x)-1,readline().split())

    uf=UnionFind(n)
    cnt=[0]*m
    now=n*(n-1)//2
    j=-1
    for i in range(m-1,-1,-1):
        cnt[j]=now
        if uf.are_same(a[i],b[i])==False:
            now=max(0,now-uf.element_count(a[i])*uf.element_count(b[i]))
            uf.union(a[i],b[i])
        j-=1

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

if __name__=="__main__":
    main() class UnionFind:
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
        self.rank=[0]*n

    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return 

        if self.rank[x]<self.rank[y]:
            self.parents[y]+=self.parents[x]
            self.parents[x]=y
        else:
            self.parents[x]+=self.parents[y]
            self.parents[y]=x

            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def are_same(self,x,y):
        return self.find(x)==self.find(y)

    def element_count(self,x):
        x=self.find(x)
        return -self.parents[x]

    def group_count(self):
        count=0
        for e in self.parents:
            if e<0: count+=1
        return count UnionFind def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
        self.rank=[0]*n

     __init__ self.n=n self.n self n n self.parents=[-1]*n self.parents self parents [-1]*n [-1] -1 n self.rank=[0]*n self.rank self rank [0]*n [0] 0 n self self n n def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

     find if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

     self.parents[x]<0 self.parents[x] self.parents self parents x 0 return x x self.parents[x]=self.find(self.parents[x]) self.parents[x] self.parents self parents x self.find(self.parents[x]) self.find self find self.parents[x] self.parents self parents x return self.parents[x] self.parents[x] self.parents self parents x self self x x def union(self,x,y):
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return 

        if self.rank[x]<self.rank[y]:
            self.parents[y]+=self.parents[x]
            self.parents[x]=y
        else:
            self.parents[x]+=self.parents[y]
            self.parents[y]=x

            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

     union x=self.find(x) x self.find(x) self.find self find x y=self.find(y) y self.find(y) self.find self find y if x==y:
            return 

         x==y x y return if self.rank[x]<self.rank[y]:
            self.parents[y]+=self.parents[x]
            self.parents[x]=y
        else:
            self.parents[x]+=self.parents[y]
            self.parents[y]=x

            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

     self.rank[x]<self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.parents[y]+=self.parents[x] self.parents[y] self.parents self parents y self.parents[x] self.parents self parents x self.parents[x]=y self.parents[x] self.parents self parents x y self.parents[x]+=self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y self.parents[y]=x self.parents[y] self.parents self parents y x if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

     self.rank[x]==self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.rank[x]+=1 self.rank[x] self.rank self rank x 1 self self x x y y def are_same(self,x,y):
        return self.find(x)==self.find(y)

     are_same return self.find(x)==self.find(y) self.find(x)==self.find(y) self.find(x) self.find self find x self.find(y) self.find self find y self self x x y y def element_count(self,x):
        x=self.find(x)
        return -self.parents[x]

     element_count x=self.find(x) x self.find(x) self.find self find x return -self.parents[x] -self.parents[x] self.parents[x] self.parents self parents x self self x x def group_count(self):
        count=0
        for e in self.parents:
            if e<0: count+=1
        return count group_count count=0 count 0 for e in self.parents:
            if e<0: count+=1
         e self.parents self parents if e<0: count+=1
         e<0 e 0 return count count self self from sys import stdin def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    for i in range(m):
        a[i],b[i]=map(lambda x:int(x)-1,readline().split())

    uf=UnionFind(n)
    cnt=[0]*m
    now=n*(n-1)//2
    j=-1
    for i in range(m-1,-1,-1):
        cnt[j]=now
        if uf.are_same(a[i],b[i])==False:
            now=max(0,now-uf.element_count(a[i])*uf.element_count(b[i]))
            uf.union(a[i],b[i])
        j-=1

    for i in range(m):
        print(cnt[i]) main readline=stdin.readline readline stdin.readline stdin readline n,m=map(int,readline().split()) n map(int,readline().split()) map int readline().split() ().split () readline split m a=[0]*m a [0]*m [0] 0 m b=[0]*m b [0]*m [0] 0 m for i in range(m):
        a[i],b[i]=map(lambda x:int(x)-1,readline().split())

     i range(m) range m a[i],b[i]=map(lambda x:int(x)-1,readline().split()) a[i] a i map(lambda x:int(x)-1,readline().split()) map lambda x:int(x)-1 int(x)-1 int(x) int x 1 x readline().split() ().split () readline split b[i] b i uf=UnionFind(n) uf UnionFind(n) UnionFind n cnt=[0]*m cnt [0]*m [0] 0 m now=n*(n-1)//2 now n*(n-1)//2 n*(n-1) n n-1 n 1 2 j=-1 j -1 for i in range(m-1,-1,-1):
        cnt[j]=now
        if uf.are_same(a[i],b[i])==False:
            now=max(0,now-uf.element_count(a[i])*uf.element_count(b[i]))
            uf.union(a[i],b[i])
        j-=1

     i range(m-1,-1,-1) range m-1 m 1 -1 -1 cnt[j]=now cnt[j] cnt j now if uf.are_same(a[i],b[i])==False:
            now=max(0,now-uf.element_count(a[i])*uf.element_count(b[i]))
            uf.union(a[i],b[i])
         uf.are_same(a[i],b[i])==False uf.are_same(a[i],b[i]) uf.are_same uf are_same a[i] a i b[i] b i False now=max(0,now-uf.element_count(a[i])*uf.element_count(b[i])) now max(0,now-uf.element_count(a[i])*uf.element_count(b[i])) max 0 now-uf.element_count(a[i])*uf.element_count(b[i]) now uf.element_count(a[i])*uf.element_count(b[i]) uf.element_count(a[i]) uf.element_count uf element_count a[i] a i uf.element_count(b[i]) uf.element_count uf element_count b[i] b i uf.union(a[i],b[i]) uf.union uf union a[i] a i b[i] b i j-=1 j 1 for i in range(m):
        print(cnt[i]) i range(m) range m print(cnt[i]) print cnt[i] cnt i if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main class UnionFind:
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
        self.rank=[0]*n

    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return 

        if self.rank[x]<self.rank[y]:
            self.parents[y]+=self.parents[x]
            self.parents[x]=y
        else:
            self.parents[x]+=self.parents[y]
            self.parents[y]=x

            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def are_same(self,x,y):
        return self.find(x)==self.find(y)

    def element_count(self,x):
        x=self.find(x)
        return -self.parents[x]

    def group_count(self):
        count=0
        for e in self.parents:
            if e<0: count+=1
        return count class UnionFind:
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
        self.rank=[0]*n

    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return 

        if self.rank[x]<self.rank[y]:
            self.parents[y]+=self.parents[x]
            self.parents[x]=y
        else:
            self.parents[x]+=self.parents[y]
            self.parents[y]=x

            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def are_same(self,x,y):
        return self.find(x)==self.find(y)

    def element_count(self,x):
        x=self.find(x)
        return -self.parents[x]

    def group_count(self):
        count=0
        for e in self.parents:
            if e<0: count+=1
        return count UnionFind def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    for i in range(m):
        a[i],b[i]=map(lambda x:int(x)-1,readline().split())

    uf=UnionFind(n)
    cnt=[0]*m
    now=n*(n-1)//2
    j=-1
    for i in range(m-1,-1,-1):
        cnt[j]=now
        if uf.are_same(a[i],b[i])==False:
            now=max(0,now-uf.element_count(a[i])*uf.element_count(b[i]))
            uf.union(a[i],b[i])
        j-=1

    for i in range(m):
        print(cnt[i]) def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    for i in range(m):
        a[i],b[i]=map(lambda x:int(x)-1,readline().split())

    uf=UnionFind(n)
    cnt=[0]*m
    now=n*(n-1)//2
    j=-1
    for i in range(m-1,-1,-1):
        cnt[j]=now
        if uf.are_same(a[i],b[i])==False:
            now=max(0,now-uf.element_count(a[i])*uf.element_count(b[i]))
            uf.union(a[i],b[i])
        j-=1

    for i in range(m):
        print(cnt[i]) main
class UnionFind:
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
        self.rank=[0]*n

    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return 

        if self.rank[x]<self.rank[y]:
            self.parents[y]+=self.parents[x]
            self.parents[x]=y
        else:
            self.parents[x]+=self.parents[y]
            self.parents[y]=x

            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def are_same(self,x,y):
        return self.find(x)==self.find(y)

    def element_count(self,x):
        x=self.find(x)
        return -self.parents[x]

    def group_count(self):
        count=0
        for e in self.parents:
            if e<0: count+=1
        return count

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    for i in range(m):
        a[i],b[i]=map(lambda x:int(x)-1,readline().split())

    uf=UnionFind(n)
    cnt=[0]*m
    now=n*(n-1)//2
    j=-1
    for i in range(m-1,-1,-1):
        cnt[j]=now
        if uf.are_same(a[i],b[i])==False:
            now=max(0,now-uf.element_count(a[i])*uf.element_count(b[i]))
            uf.union(a[i],b[i])
        j-=1

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

if __name__=="__main__":
    main()