class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [-1]*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 same(self,x,y):
        return self.find(x)==self.find(y)
    
    def size(self,x):
        return -self.parents[self.find(x)]
    
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x ==y: return 
        if self.parents[x]>self.parents[y]:
            x,y = y,x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

N,M = map(int,input().split())
edge = []
uf = UnionFind(N)
for i in range(M):
    a,b = map(int,input().split())
    edge.append((a-1,b-1))
ans = N*(N-1)//2
l = []
for i in range(M)[::-1]:
    l.append(ans)
    if not uf.same(edge[i][0],edge[i][1]):
        ans -= uf.size(edge[i][0])*uf.size(edge[i][1])
    uf.union(edge[i][0],edge[i][1])
print(*l[::-1], sep="\n") class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [-1]*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 same(self,x,y):
        return self.find(x)==self.find(y)
    
    def size(self,x):
        return -self.parents[self.find(x)]
    
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x ==y: return 
        if self.parents[x]>self.parents[y]:
            x,y = y,x
        self.parents[x] += self.parents[y]
        self.parents[y] = x UnionFind def __init__(self,n):
        self.n = n
        self.parents = [-1]*n
    
     __init__ self.n = n self.n self n n self.parents = [-1]*n self.parents self parents [-1]*n [-1] -1 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 same(self,x,y):
        return self.find(x)==self.find(y)
    
     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 size(self,x):
        return -self.parents[self.find(x)]
    
    
     size return -self.parents[self.find(x)] -self.parents[self.find(x)] self.parents[self.find(x)] self.parents self parents self.find(x) self.find self find x self self x x def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x ==y: return 
        if self.parents[x]>self.parents[y]:
            x,y = y,x
        self.parents[x] += self.parents[y]
        self.parents[y] = x 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 if self.parents[x]>self.parents[y]:
            x,y = y,x
         self.parents[x]>self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y x,y = y,x x y y x 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 self self x x y y N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M edge = [] edge [] uf = UnionFind(N) uf UnionFind(N) UnionFind N for i in range(M):
    a,b = map(int,input().split())
    edge.append((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 edge.append((a-1,b-1)) edge.append edge append (a-1,b-1) a-1 a 1 b-1 b 1 ans = N*(N-1)//2 ans N*(N-1)//2 N*(N-1) N N-1 N 1 2 l = [] l [] for i in range(M)[::-1]:
    l.append(ans)
    if not uf.same(edge[i][0],edge[i][1]):
        ans -= uf.size(edge[i][0])*uf.size(edge[i][1])
    uf.union(edge[i][0],edge[i][1]) i range(M)[::-1] (M) range M ::-1 -1 l.append(ans) l.append l append ans if not uf.same(edge[i][0],edge[i][1]):
        ans -= uf.size(edge[i][0])*uf.size(edge[i][1])
     not uf.same(edge[i][0],edge[i][1]) uf.same(edge[i][0],edge[i][1]) uf.same uf same edge[i][0] [i] edge i 0 edge[i][1] [i] edge i 1 ans -= uf.size(edge[i][0])*uf.size(edge[i][1]) ans uf.size(edge[i][0])*uf.size(edge[i][1]) uf.size(edge[i][0]) uf.size uf size edge[i][0] [i] edge i 0 uf.size(edge[i][1]) uf.size uf size edge[i][1] [i] edge i 1 uf.union(edge[i][0],edge[i][1]) uf.union uf union edge[i][0] [i] edge i 0 edge[i][1] [i] edge i 1 print(*l[::-1], sep="\n") print *l[::-1] l[::-1] l ::-1 -1 sep="\n" sep "\n" class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [-1]*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 same(self,x,y):
        return self.find(x)==self.find(y)
    
    def size(self,x):
        return -self.parents[self.find(x)]
    
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x ==y: return 
        if self.parents[x]>self.parents[y]:
            x,y = y,x
        self.parents[x] += self.parents[y]
        self.parents[y] = x class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [-1]*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 same(self,x,y):
        return self.find(x)==self.find(y)
    
    def size(self,x):
        return -self.parents[self.find(x)]
    
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x ==y: return 
        if self.parents[x]>self.parents[y]:
            x,y = y,x
        self.parents[x] += self.parents[y]
        self.parents[y] = x UnionFind N,M = map(int,input().split()) map(int,input().split()) N a,b = map(int,input().split()) map(int,input().split()) a uf = UnionFind(N) UnionFind(N) uf l = [] [] l b = map(int,input().split()) map(int,input().split()) b M = map(int,input().split()) map(int,input().split()) M edge = [] [] edge ans -= uf.size(edge[i][0])*uf.size(edge[i][1]) uf.size(edge[i][0])*uf.size(edge[i][1]) ans ans = N*(N-1)//2 N*(N-1)//2 ans
class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [-1]*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 same(self,x,y):
        return self.find(x)==self.find(y)
    
    def size(self,x):
        return -self.parents[self.find(x)]
    
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x ==y: return 
        if self.parents[x]>self.parents[y]:
            x,y = y,x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

N,M = map(int,input().split())
edge = []
uf = UnionFind(N)
for i in range(M):
    a,b = map(int,input().split())
    edge.append((a-1,b-1))
ans = N*(N-1)//2
l = []
for i in range(M)[::-1]:
    l.append(ans)
    if not uf.same(edge[i][0],edge[i][1]):
        ans -= uf.size(edge[i][0])*uf.size(edge[i][1])
    uf.union(edge[i][0],edge[i][1])
print(*l[::-1], sep="\n")