#UnionFind木
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    #parents属性は根でない場合は自分の親の番号だが、
    #根の場合は負の数で、絶対値がグループのメンバ数を表す

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

N, M = map(int, input().split())

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

uf = UnionFind(N)
total = N*(N-1)//2
ans = [total]

for i in range(M):
  if uf.same(A[i],B[i]):
    ans.append(total)
    continue
  total -= uf.nums(A[i])*uf.nums(B[i])
  uf.union(A[i],B[i])
  ans.append(total)
  
#print(ans)   
print(*ans[-2::-1], sep='\n') class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    #parents属性は根でない場合は自分の親の番号だが、
    #根の場合は負の数で、絶対値がグループのメンバ数を表す

  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 nums(self,x):
    return abs(self.parents[self.find(x)]) UnionFind def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    #parents属性は根でない場合は自分の親の番号だが、
    #根の場合は負の数で、絶対値がグループのメンバ数を表す

   __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 nums(self,x):
    return abs(self.parents[self.find(x)]) nums return abs(self.parents[self.find(x)]) abs(self.parents[self.find(x)]) abs 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 = [0]*M A [0]*M [0] 0 M B = [0]*M B [0]*M [0] 0 M for i in range(M-1,-1,-1):
  A[i],B[i] = map(int, input().split())
  A[i] -= 1
  B[i] -= 1 i range(M-1,-1,-1) range M-1 M 1 -1 -1 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 A[i] -= 1 A[i] A i 1 B[i] -= 1 B[i] B i 1 uf = UnionFind(N) uf UnionFind(N) UnionFind N total = N*(N-1)//2 total N*(N-1)//2 N*(N-1) N N-1 N 1 2 ans = [total] ans [total] total for i in range(M):
  if uf.same(A[i],B[i]):
    ans.append(total)
    continue
  total -= uf.nums(A[i])*uf.nums(B[i])
  uf.union(A[i],B[i])
  ans.append(total)
  
#print(ans)    i range(M) range M if uf.same(A[i],B[i]):
    ans.append(total)
    continue
   uf.same(A[i],B[i]) uf.same uf same A[i] A i B[i] B i ans.append(total) ans.append ans append total continue total -= uf.nums(A[i])*uf.nums(B[i]) total uf.nums(A[i])*uf.nums(B[i]) uf.nums(A[i]) uf.nums uf nums A[i] A i uf.nums(B[i]) uf.nums uf nums B[i] B i uf.union(A[i],B[i]) uf.union uf union A[i] A i B[i] B i ans.append(total) ans.append ans append total print(*ans[-2::-1], sep='\n') print *ans[-2::-1] ans[-2::-1] ans -2::-1 -2 -1 sep='\n' sep '\n' B = [0]*M [0]*M B N, M = map(int, input().split()) map(int, input().split()) N ans = [total] [total] ans M = map(int, input().split()) map(int, input().split()) M total -= uf.nums(A[i])*uf.nums(B[i]) uf.nums(A[i])*uf.nums(B[i]) total class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    #parents属性は根でない場合は自分の親の番号だが、
    #根の場合は負の数で、絶対値がグループのメンバ数を表す

  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 nums(self,x):
    return abs(self.parents[self.find(x)]) class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    #parents属性は根でない場合は自分の親の番号だが、
    #根の場合は負の数で、絶対値がグループのメンバ数を表す

  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 nums(self,x):
    return abs(self.parents[self.find(x)]) UnionFind uf = UnionFind(N) UnionFind(N) uf A = [0]*M [0]*M A total = N*(N-1)//2 N*(N-1)//2 total
#UnionFind木
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    #parents属性は根でない場合は自分の親の番号だが、
    #根の場合は負の数で、絶対値がグループのメンバ数を表す

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

N, M = map(int, input().split())

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

uf = UnionFind(N)
total = N*(N-1)//2
ans = [total]

for i in range(M):
  if uf.same(A[i],B[i]):
    ans.append(total)
    continue
  total -= uf.nums(A[i])*uf.nums(B[i])
  uf.union(A[i],B[i])
  ans.append(total)
  
#print(ans)   
print(*ans[-2::-1], sep='\n')
