N,M = map(int,(input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
    A[i],B[i] = map(int,(input().split()))
bridge = [[] for _ in range(N)]

# UnionFind
class UnionFind:

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

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

        if x == y:
            return
        else:
            if self.rank[x] <self.rank[y]:
                self.par[y] += self.par[x] # 負+負でsize管理 
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]

Tree = UnionFind(N)
isolated = N*(N-1)//2
ans = []
ans.append(isolated)
for i in range(1,M)[::-1]:
    if not Tree.is_same(A[i]-1,B[i]-1):
        isolated -= Tree.size(A[i]-1) * Tree.size(B[i]-1)
    Tree.union(A[i]-1,B[i]-1)
    ans.append(isolated)

ans.reverse()
for i in range(M):
    print(ans[i]) N,M = map(int,(input().split())) N map(int,(input().split())) map int input().split() ().split () input 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(int,(input().split())) i range(M) range M A[i],B[i] = map(int,(input().split())) A[i] A i map(int,(input().split())) map int input().split() ().split () input split B[i] B i [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] bridge = [[] for _ in range(N)] bridge [[] for _ in range(N)] class UnionFind:

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

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

        if x == y:
            return
        else:
            if self.rank[x] <self.rank[y]:
                self.par[y] += self.par[x] # 負+負でsize管理 
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)] UnionFind def __init__(self, n):
        self.par =  [-1] * n
        self.rank = [0] * n
    
     __init__ self.par =  [-1] * n self.par self par [-1] * n [-1] -1 n self.rank = [0] * n self.rank self rank [0] * n [0] 0 n self self n n def root(self,x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

     root if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

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

        if x == y:
            return
        else:
            if self.rank[x] <self.rank[y]:
                self.par[y] += self.par[x] # 負+負でsize管理 
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    self.rank[x] += 1
    
     union x = self.root(x) x self.root(x) self.root self root x y = self.root(y) y self.root(y) self.root self root y if x == y:
            return
        else:
            if self.rank[x] <self.rank[y]:
                self.par[y] += self.par[x] # 負+負でsize管理 
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    self.rank[x] += 1
    
     x == y x y return if self.rank[x] <self.rank[y]:
                self.par[y] += self.par[x] # 負+負でsize管理 
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    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.par[y] += self.par[x] self.par[y] self.par self par y self.par[x] self.par self par x self.par[x] = y self.par[x] self.par self par x y self.par[x] += self.par[y] self.par[x] self.par self par x self.par[y] self.par self par y self.par[y] = x self.par[y] self.par self par y x if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    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 is_same(self, x, y):
        return self.root(x) == self.root(y)

     is_same 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 size(self, x):
        return -self.par[self.root(x)] size return -self.par[self.root(x)] -self.par[self.root(x)] self.par[self.root(x)] self.par self par self.root(x) self.root self root x self self x x Tree = UnionFind(N) Tree UnionFind(N) UnionFind N isolated = N*(N-1)//2 isolated N*(N-1)//2 N*(N-1) N N-1 N 1 2 ans = [] ans [] ans.append(isolated) ans.append ans append isolated for i in range(1,M)[::-1]:
    if not Tree.is_same(A[i]-1,B[i]-1):
        isolated -= Tree.size(A[i]-1) * Tree.size(B[i]-1)
    Tree.union(A[i]-1,B[i]-1)
    ans.append(isolated) i range(1,M)[::-1] (1,M) range 1 M ::-1 -1 if not Tree.is_same(A[i]-1,B[i]-1):
        isolated -= Tree.size(A[i]-1) * Tree.size(B[i]-1)
     not Tree.is_same(A[i]-1,B[i]-1) Tree.is_same(A[i]-1,B[i]-1) Tree.is_same Tree is_same A[i]-1 A[i] A i 1 B[i]-1 B[i] B i 1 isolated -= Tree.size(A[i]-1) * Tree.size(B[i]-1) isolated Tree.size(A[i]-1) * Tree.size(B[i]-1) Tree.size(A[i]-1) Tree.size Tree size A[i]-1 A[i] A i 1 Tree.size(B[i]-1) Tree.size Tree size B[i]-1 B[i] B i 1 Tree.union(A[i]-1,B[i]-1) Tree.union Tree union A[i]-1 A[i] A i 1 B[i]-1 B[i] B i 1 ans.append(isolated) ans.append ans append isolated ans.reverse() ans.reverse ans reverse for i in range(M):
    print(ans[i]) i range(M) range M print(ans[i]) print ans[i] ans i isolated = N*(N-1)//2 N*(N-1)//2 isolated isolated -= Tree.size(A[i]-1) * Tree.size(B[i]-1) Tree.size(A[i]-1) * Tree.size(B[i]-1) isolated M = map(int,(input().split())) map(int,(input().split())) M ans = [] [] ans class UnionFind:

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

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

        if x == y:
            return
        else:
            if self.rank[x] <self.rank[y]:
                self.par[y] += self.par[x] # 負+負でsize管理 
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)] class UnionFind:

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

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

        if x == y:
            return
        else:
            if self.rank[x] <self.rank[y]:
                self.par[y] += self.par[x] # 負+負でsize管理 
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)] UnionFind B = [0]*M [0]*M B N,M = map(int,(input().split())) map(int,(input().split())) N A = [0]*M [0]*M A Tree = UnionFind(N) UnionFind(N) Tree bridge = [[] for _ in range(N)] [[] for _ in range(N)] bridge
N,M = map(int,(input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
    A[i],B[i] = map(int,(input().split()))
bridge = [[] for _ in range(N)]

# UnionFind
class UnionFind:

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

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

        if x == y:
            return
        else:
            if self.rank[x] <self.rank[y]:
                self.par[y] += self.par[x] # 負+負でsize管理 
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]: # 負+負でsize管理 
                    self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]

Tree = UnionFind(N)
isolated = N*(N-1)//2
ans = []
ans.append(isolated)
for i in range(1,M)[::-1]:
    if not Tree.is_same(A[i]-1,B[i]-1):
        isolated -= Tree.size(A[i]-1) * Tree.size(B[i]-1)
    Tree.union(A[i]-1,B[i]-1)
    ans.append(isolated)

ans.reverse()
for i in range(M):
    print(ans[i])