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

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

N, M = map(int, input().split())
A = list()
B = list()
for j in range(M):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
ans = [0] * M
ans[M-1] = N*(N-1)//2
uf = UnionFind(N+1)
for i in range(M-1, 0, -1):
  a = A[i]
  b = B[i]
  if uf.same(a,b): 
    ans[i-1] = ans[i]
  else:
    ans[i-1] = ans[i] - uf.size(a)*uf.size(b)
  uf.union(a, b)
    
for i in range(M):
  print(ans[i])