N, M = list(map(int,input().split()))
in_ = []
for i in range(M):
    a, b = map(int, input().split())
    in_.append([a, b])

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 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
    
    def size(self, x):  return -self.parents[self.find(x)]

    def same(self, x, y):  return self.find(x) == self.find(y)
        
uf = UnionFind(N)
cnt = N * (N - 1) // 2
ans = [0 for _ in range(M)]

for i in range(M):
    ans[-i - 1] = cnt
    a, b = in_[-i - 1][0] - 1, in_[-i - 1][1] - 1
    if uf.same(a, b):  continue
    cnt -= (uf.size(a) * uf.size(b))
    uf.union(a, b)

for i in range(M):  print(ans[i]) N, M = list(map(int,input().split())) N list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split M in_ = [] in_ [] for i in range(M):
    a, b = map(int, input().split())
    in_.append([a, b]) i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b in_.append([a, b]) in_.append in_ append [a, b] a b 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 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
    
    def size(self, x):  return -self.parents[self.find(x)]

    def same(self, x, y):  return self.find(x) == self.find(y)
         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 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.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 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 def size(self, x):  return -self.parents[self.find(x)]

     size self self x x def same(self, x, y):  return self.find(x) == self.find(y)
         same self self x x y y uf = UnionFind(N) uf UnionFind(N) UnionFind N cnt = N * (N - 1) // 2 cnt N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 0 for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) 0 ans = [0 for _ in range(M)] ans [0 for _ in range(M)] for i in range(M):
    ans[-i - 1] = cnt
    a, b = in_[-i - 1][0] - 1, in_[-i - 1][1] - 1
    if uf.same(a, b):  continue
    cnt -= (uf.size(a) * uf.size(b))
    uf.union(a, b) i range(M) range M ans[-i - 1] = cnt ans[-i - 1] ans -i - 1 -i i 1 cnt a, b = in_[-i - 1][0] - 1, in_[-i - 1][1] - 1 a in_[-i - 1][0] - 1 in_[-i - 1][0] [-i - 1] in_ -i - 1 -i i 1 0 1 b in_[-i - 1][1] - 1 in_[-i - 1][1] [-i - 1] in_ -i - 1 -i i 1 1 1 if uf.same(a, b):  continue
     uf.same(a, b) uf.same uf same a b cnt -= (uf.size(a) * uf.size(b)) cnt uf.size(a) * uf.size(b) uf.size(a) uf.size uf size a uf.size(b) uf.size uf size b uf.union(a, b) uf.union uf union a b for i in range(M):  print(ans[i]) i range(M) range M b = in_[-i - 1][0] - 1, in_[-i - 1][1] - 1 in_[-i - 1][1] - 1 b a, b = map(int, input().split()) map(int, input().split()) a b = map(int, input().split()) map(int, input().split()) b 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 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
    
    def size(self, x):  return -self.parents[self.find(x)]

    def same(self, x, y):  return self.find(x) == self.find(y)
         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 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
    
    def size(self, x):  return -self.parents[self.find(x)]

    def same(self, x, y):  return self.find(x) == self.find(y)
         UnionFind cnt -= (uf.size(a) * uf.size(b)) uf.size(a) * uf.size(b) cnt M = list(map(int,input().split())) list(map(int,input().split())) M cnt = N * (N - 1) // 2 N * (N - 1) // 2 cnt ans = [0 for _ in range(M)] [0 for _ in range(M)] ans a, b = in_[-i - 1][0] - 1, in_[-i - 1][1] - 1 in_[-i - 1][0] - 1 a N, M = list(map(int,input().split())) list(map(int,input().split())) N uf = UnionFind(N) UnionFind(N) uf in_ = [] [] in_
N, M = list(map(int,input().split()))
in_ = []
for i in range(M):
    a, b = map(int, input().split())
    in_.append([a, b])

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 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
    
    def size(self, x):  return -self.parents[self.find(x)]

    def same(self, x, y):  return self.find(x) == self.find(y)
        
uf = UnionFind(N)
cnt = N * (N - 1) // 2
ans = [0 for _ in range(M)]

for i in range(M):
    ans[-i - 1] = cnt
    a, b = in_[-i - 1][0] - 1, in_[-i - 1][1] - 1
    if uf.same(a, b):  continue
    cnt -= (uf.size(a) * uf.size(b))
    uf.union(a, b)

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