# ABC120D

import sys
input=sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.p=[-1]*n
        self.size=[1]*n
        
    def root(self, x):
        st=set()
        while self.p[x]>=0:
            st.add(x)
            x=self.p[x]
        for y in st:
            self.p[y]=x
        return x
    def find(self, x, y):
        return self.root(x)==self.root(y)
    def union(self, x, y):
        r1=self.root(x)
        r2=self.root(y)
        if r1==r2:
            return
        p1=self.p[r1]
        p2=self.p[r2]
        if p1<=p2:
            self.p[r2]=r1
            self.size[r1]+=self.size[r2]
            if p1==p2:
                self.p[r1]-=1
        else:
            self.p[r1]=r2
            self.size[r2]+=self.size[r1]

    
def main():
    N,M=map(int,input().split())
    AB=[tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
    
    uft=UnionFind(N)
    ansl=[int(N*(N-1)//2)]
    for i in range(M-1,0,-1):
        a=AB[i][0]
        b=AB[i][1]
        if not uft.find(a,b):
            ansl.append(ansl[-1]-( uft.size[uft.root(a)]*uft.size[uft.root(b)] ))
        else:
            ansl.append(ansl[-1])
        uft.union(a,b)
        
    for i in range(M-1,-1,-1):
        print(ansl[i])
    
    
    
    
if __name__=="__main__":
    main() import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class UnionFind:
    def __init__(self, n):
        self.p=[-1]*n
        self.size=[1]*n
        
    def root(self, x):
        st=set()
        while self.p[x]>=0:
            st.add(x)
            x=self.p[x]
        for y in st:
            self.p[y]=x
        return x
    def find(self, x, y):
        return self.root(x)==self.root(y)
    def union(self, x, y):
        r1=self.root(x)
        r2=self.root(y)
        if r1==r2:
            return
        p1=self.p[r1]
        p2=self.p[r2]
        if p1<=p2:
            self.p[r2]=r1
            self.size[r1]+=self.size[r2]
            if p1==p2:
                self.p[r1]-=1
        else:
            self.p[r1]=r2
            self.size[r2]+=self.size[r1]

     UnionFind def __init__(self, n):
        self.p=[-1]*n
        self.size=[1]*n
        
     __init__ self.p=[-1]*n self.p self p [-1]*n [-1] -1 n self.size=[1]*n self.size self size [1]*n [1] 1 n self self n n def root(self, x):
        st=set()
        while self.p[x]>=0:
            st.add(x)
            x=self.p[x]
        for y in st:
            self.p[y]=x
        return x
     root st=set() st set() set while self.p[x]>=0:
            st.add(x)
            x=self.p[x]
         self.p[x]>=0 self.p[x] self.p self p x 0 st.add(x) st.add st add x x=self.p[x] x self.p[x] self.p self p x for y in st:
            self.p[y]=x
         y st self.p[y]=x self.p[y] self.p self p y x return x x self self x x def find(self, x, y):
        return self.root(x)==self.root(y)
     find return self.root(x)==self.root(y) self.root(x)==self.root(y) self.root(x) self.root self root x self.root(y) self.root self root y self self x x y y def union(self, x, y):
        r1=self.root(x)
        r2=self.root(y)
        if r1==r2:
            return
        p1=self.p[r1]
        p2=self.p[r2]
        if p1<=p2:
            self.p[r2]=r1
            self.size[r1]+=self.size[r2]
            if p1==p2:
                self.p[r1]-=1
        else:
            self.p[r1]=r2
            self.size[r2]+=self.size[r1]

     union r1=self.root(x) r1 self.root(x) self.root self root x r2=self.root(y) r2 self.root(y) self.root self root y if r1==r2:
            return
         r1==r2 r1 r2 return p1=self.p[r1] p1 self.p[r1] self.p self p r1 p2=self.p[r2] p2 self.p[r2] self.p self p r2 if p1<=p2:
            self.p[r2]=r1
            self.size[r1]+=self.size[r2]
            if p1==p2:
                self.p[r1]-=1
        else:
            self.p[r1]=r2
            self.size[r2]+=self.size[r1]

     p1<=p2 p1 p2 self.p[r2]=r1 self.p[r2] self.p self p r2 r1 self.size[r1]+=self.size[r2] self.size[r1] self.size self size r1 self.size[r2] self.size self size r2 if p1==p2:
                self.p[r1]-=1
         p1==p2 p1 p2 self.p[r1]-=1 self.p[r1] self.p self p r1 1 self.p[r1]=r2 self.p[r1] self.p self p r1 r2 self.size[r2]+=self.size[r1] self.size[r2] self.size self size r2 self.size[r1] self.size self size r1 self self x x y y def main():
    N,M=map(int,input().split())
    AB=[tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
    
    uft=UnionFind(N)
    ansl=[int(N*(N-1)//2)]
    for i in range(M-1,0,-1):
        a=AB[i][0]
        b=AB[i][1]
        if not uft.find(a,b):
            ansl.append(ansl[-1]-( uft.size[uft.root(a)]*uft.size[uft.root(b)] ))
        else:
            ansl.append(ansl[-1])
        uft.union(a,b)
        
    for i in range(M-1,-1,-1):
        print(ansl[i])
    
    
    
     main N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M tuple(map(lambda x:int(x)-1,input().split())) for i in range(M) for i in range(M) i range(M) range M for i in range(M) tuple(map(lambda x:int(x)-1,input().split())) tuple 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 AB=[tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)] AB [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)] uft=UnionFind(N) uft UnionFind(N) UnionFind N ansl=[int(N*(N-1)//2)] ansl [int(N*(N-1)//2)] int(N*(N-1)//2) int N*(N-1)//2 N*(N-1) N N-1 N 1 2 for i in range(M-1,0,-1):
        a=AB[i][0]
        b=AB[i][1]
        if not uft.find(a,b):
            ansl.append(ansl[-1]-( uft.size[uft.root(a)]*uft.size[uft.root(b)] ))
        else:
            ansl.append(ansl[-1])
        uft.union(a,b)
        
     i range(M-1,0,-1) range M-1 M 1 0 -1 a=AB[i][0] a AB[i][0] [i] AB i 0 b=AB[i][1] b AB[i][1] [i] AB i 1 if not uft.find(a,b):
            ansl.append(ansl[-1]-( uft.size[uft.root(a)]*uft.size[uft.root(b)] ))
        else:
            ansl.append(ansl[-1])
         not uft.find(a,b) uft.find(a,b) uft.find uft find a b ansl.append(ansl[-1]-( uft.size[uft.root(a)]*uft.size[uft.root(b)] )) ansl.append ansl append ansl[-1]-( uft.size[uft.root(a)]*uft.size[uft.root(b)] ) ansl[-1] ansl -1 uft.size[uft.root(a)]*uft.size[uft.root(b)] uft.size[uft.root(a)] uft.size uft size uft.root(a) uft.root uft root a uft.size[uft.root(b)] uft.size uft size uft.root(b) uft.root uft root b ansl.append(ansl[-1]) ansl.append ansl append ansl[-1] ansl -1 uft.union(a,b) uft.union uft union a b for i in range(M-1,-1,-1):
        print(ansl[i])
    
    
    
     i range(M-1,-1,-1) range M-1 M 1 -1 -1 print(ansl[i]) print ansl[i] ansl i if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def main():
    N,M=map(int,input().split())
    AB=[tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
    
    uft=UnionFind(N)
    ansl=[int(N*(N-1)//2)]
    for i in range(M-1,0,-1):
        a=AB[i][0]
        b=AB[i][1]
        if not uft.find(a,b):
            ansl.append(ansl[-1]-( uft.size[uft.root(a)]*uft.size[uft.root(b)] ))
        else:
            ansl.append(ansl[-1])
        uft.union(a,b)
        
    for i in range(M-1,-1,-1):
        print(ansl[i])
    
    
    
     def main():
    N,M=map(int,input().split())
    AB=[tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
    
    uft=UnionFind(N)
    ansl=[int(N*(N-1)//2)]
    for i in range(M-1,0,-1):
        a=AB[i][0]
        b=AB[i][1]
        if not uft.find(a,b):
            ansl.append(ansl[-1]-( uft.size[uft.root(a)]*uft.size[uft.root(b)] ))
        else:
            ansl.append(ansl[-1])
        uft.union(a,b)
        
    for i in range(M-1,-1,-1):
        print(ansl[i])
    
    
    
     main class UnionFind:
    def __init__(self, n):
        self.p=[-1]*n
        self.size=[1]*n
        
    def root(self, x):
        st=set()
        while self.p[x]>=0:
            st.add(x)
            x=self.p[x]
        for y in st:
            self.p[y]=x
        return x
    def find(self, x, y):
        return self.root(x)==self.root(y)
    def union(self, x, y):
        r1=self.root(x)
        r2=self.root(y)
        if r1==r2:
            return
        p1=self.p[r1]
        p2=self.p[r2]
        if p1<=p2:
            self.p[r2]=r1
            self.size[r1]+=self.size[r2]
            if p1==p2:
                self.p[r1]-=1
        else:
            self.p[r1]=r2
            self.size[r2]+=self.size[r1]

     class UnionFind:
    def __init__(self, n):
        self.p=[-1]*n
        self.size=[1]*n
        
    def root(self, x):
        st=set()
        while self.p[x]>=0:
            st.add(x)
            x=self.p[x]
        for y in st:
            self.p[y]=x
        return x
    def find(self, x, y):
        return self.root(x)==self.root(y)
    def union(self, x, y):
        r1=self.root(x)
        r2=self.root(y)
        if r1==r2:
            return
        p1=self.p[r1]
        p2=self.p[r2]
        if p1<=p2:
            self.p[r2]=r1
            self.size[r1]+=self.size[r2]
            if p1==p2:
                self.p[r1]-=1
        else:
            self.p[r1]=r2
            self.size[r2]+=self.size[r1]

     UnionFind input=sys.stdin.readline sys.stdin.readline input
# ABC120D

import sys
input=sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.p=[-1]*n
        self.size=[1]*n
        
    def root(self, x):
        st=set()
        while self.p[x]>=0:
            st.add(x)
            x=self.p[x]
        for y in st:
            self.p[y]=x
        return x
    def find(self, x, y):
        return self.root(x)==self.root(y)
    def union(self, x, y):
        r1=self.root(x)
        r2=self.root(y)
        if r1==r2:
            return
        p1=self.p[r1]
        p2=self.p[r2]
        if p1<=p2:
            self.p[r2]=r1
            self.size[r1]+=self.size[r2]
            if p1==p2:
                self.p[r1]-=1
        else:
            self.p[r1]=r2
            self.size[r2]+=self.size[r1]

    
def main():
    N,M=map(int,input().split())
    AB=[tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
    
    uft=UnionFind(N)
    ansl=[int(N*(N-1)//2)]
    for i in range(M-1,0,-1):
        a=AB[i][0]
        b=AB[i][1]
        if not uft.find(a,b):
            ansl.append(ansl[-1]-( uft.size[uft.root(a)]*uft.size[uft.root(b)] ))
        else:
            ansl.append(ansl[-1])
        uft.union(a,b)
        
    for i in range(M-1,-1,-1):
        print(ansl[i])
    
    
    
    
if __name__=="__main__":
    main()
