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)

n,m = map(int,input().split())
uf = UnionFind(n)

A = [0]*m
B = [0]*m

for i in range(m):
  a,b = map(int,input().split())
  A[i],B[i] = a-1, b-1

total = n*(n-1)//2  
ans = [total] 
cost = 0

for a,b in zip(A[::-1],B[::-1]):    
  if uf.same(a,b):
    ans.append(ans[-1])
  else:
    ans.append(ans[-1] - uf.size(a)*uf.size(b))
      
  uf.union(a,b)

ans.pop()
for a in ans[::-1]:
  print(a) 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 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.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 return 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 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 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 n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m uf = UnionFind(n) uf UnionFind(n) UnionFind n A = [0]*m A [0]*m [0] 0 m B = [0]*m B [0]*m [0] 0 m for i in range(m):
  a,b = map(int,input().split())
  A[i],B[i] = 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 A[i],B[i] = a-1, b-1 A[i] A i a-1 a 1 B[i] B i b-1 b 1 total = n*(n-1)//2 total n*(n-1)//2 n*(n-1) n n-1 n 1 2 ans = [total] ans [total] total cost = 0 cost 0 for a,b in zip(A[::-1],B[::-1]):    
  if uf.same(a,b):
    ans.append(ans[-1])
  else:
    ans.append(ans[-1] - uf.size(a)*uf.size(b))
      
  uf.union(a,b) a b zip(A[::-1],B[::-1]) zip A[::-1] A ::-1 -1 B[::-1] B ::-1 -1 if uf.same(a,b):
    ans.append(ans[-1])
  else:
    ans.append(ans[-1] - uf.size(a)*uf.size(b))
      
   uf.same(a,b) uf.same uf same a b ans.append(ans[-1]) ans.append ans append ans[-1] ans -1 ans.append(ans[-1] - uf.size(a)*uf.size(b)) ans.append ans append ans[-1] - uf.size(a)*uf.size(b) ans[-1] ans -1 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 ans.pop() ans.pop ans pop for a in ans[::-1]:
  print(a) a ans[::-1] ans ::-1 -1 print(a) print a B = [0]*m [0]*m B A = [0]*m [0]*m A cost = 0 0 cost n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m total = n*(n-1)//2 n*(n-1)//2 total 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 ans = [total] [total] ans uf = UnionFind(n) UnionFind(n) uf 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)

n,m = map(int,input().split())
uf = UnionFind(n)

A = [0]*m
B = [0]*m

for i in range(m):
  a,b = map(int,input().split())
  A[i],B[i] = a-1, b-1

total = n*(n-1)//2  
ans = [total] 
cost = 0

for a,b in zip(A[::-1],B[::-1]):    
  if uf.same(a,b):
    ans.append(ans[-1])
  else:
    ans.append(ans[-1] - uf.size(a)*uf.size(b))
      
  uf.union(a,b)

ans.pop()
for a in ans[::-1]:
  print(a)