class UF():
  def __init__(self, N):
    self.parents = [-1] * N

  def find(self, n):
    if self.parents[n] < 0:
      return n
    else:
      self.parents[n] = self.find(self.parents[n])
      return self.parents[n]

  def union(self, u,v):
    p1,p2 = self.find(u),self.find(v)
    if p1==p2: return
    if p1 > p2:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

  def same(self, u,v):
    return self.find(u) == self.find(v)

  def weight(self, u):
    p = self.find(u)
    return -self.parents[p]

n,m = map(int,input().split())
edges = []
for _ in range(m):
  u,v = map(int,input().split())
  edges.append((u,v))
edges.reverse()

uf = UF(n+1)

ans = [n*(n-1)//2]
for i in range(m-1):
  if ans[-1] == 0:
    ans.append(0)
  else:
    u,v = edges[i]
    if uf.same(u,v):
      ans.append(ans[-1])
    else:
      w1,w2 = uf.weight(u), uf.weight(v)
      ans.append(ans[-1]-w1*w2)
      uf.union(u,v)

for a in ans[::-1]:
  print(a) class UF():
  def __init__(self, N):
    self.parents = [-1] * N

  def find(self, n):
    if self.parents[n] < 0:
      return n
    else:
      self.parents[n] = self.find(self.parents[n])
      return self.parents[n]

  def union(self, u,v):
    p1,p2 = self.find(u),self.find(v)
    if p1==p2: return
    if p1 > p2:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

  def same(self, u,v):
    return self.find(u) == self.find(v)

  def weight(self, u):
    p = self.find(u)
    return -self.parents[p] UF def __init__(self, N):
    self.parents = [-1] * N

   __init__ self.parents = [-1] * N self.parents self parents [-1] * N [-1] -1 N self self N N def find(self, n):
    if self.parents[n] < 0:
      return n
    else:
      self.parents[n] = self.find(self.parents[n])
      return self.parents[n]

   find if self.parents[n] < 0:
      return n
    else:
      self.parents[n] = self.find(self.parents[n])
      return self.parents[n]

   self.parents[n] < 0 self.parents[n] self.parents self parents n 0 return n n self.parents[n] = self.find(self.parents[n]) self.parents[n] self.parents self parents n self.find(self.parents[n]) self.find self find self.parents[n] self.parents self parents n return self.parents[n] self.parents[n] self.parents self parents n self self n n def union(self, u,v):
    p1,p2 = self.find(u),self.find(v)
    if p1==p2: return
    if p1 > p2:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

   union p1,p2 = self.find(u),self.find(v) p1 self.find(u) self.find self find u p2 self.find(v) self.find self find v if p1==p2: return
     p1==p2 p1 p2 if p1 > p2:
      p1,p2 = p2,p1
     p1 > p2 p1 p2 p1,p2 = p2,p1 p1 p2 p2 p1 self.parents[p1] += self.parents[p2] self.parents[p1] self.parents self parents p1 self.parents[p2] self.parents self parents p2 self.parents[p2] = p1 self.parents[p2] self.parents self parents p2 p1 self self u u v v def same(self, u,v):
    return self.find(u) == self.find(v)

   same return self.find(u) == self.find(v) self.find(u) == self.find(v) self.find(u) self.find self find u self.find(v) self.find self find v self self u u v v def weight(self, u):
    p = self.find(u)
    return -self.parents[p] weight p = self.find(u) p self.find(u) self.find self find u return -self.parents[p] -self.parents[p] self.parents[p] self.parents self parents p self self u u n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m edges = [] edges [] for _ in range(m):
  u,v = map(int,input().split())
  edges.append((u,v)) _ range(m) range m u,v = map(int,input().split()) u map(int,input().split()) map int input().split() ().split () input split v edges.append((u,v)) edges.append edges append (u,v) u v edges.reverse() edges.reverse edges reverse uf = UF(n+1) uf UF(n+1) UF n+1 n 1 ans = [n*(n-1)//2] ans [n*(n-1)//2] n*(n-1)//2 n*(n-1) n n-1 n 1 2 for i in range(m-1):
  if ans[-1] == 0:
    ans.append(0)
  else:
    u,v = edges[i]
    if uf.same(u,v):
      ans.append(ans[-1])
    else:
      w1,w2 = uf.weight(u), uf.weight(v)
      ans.append(ans[-1]-w1*w2)
      uf.union(u,v) i range(m-1) range m-1 m 1 if ans[-1] == 0:
    ans.append(0)
  else:
    u,v = edges[i]
    if uf.same(u,v):
      ans.append(ans[-1])
    else:
      w1,w2 = uf.weight(u), uf.weight(v)
      ans.append(ans[-1]-w1*w2)
      uf.union(u,v) ans[-1] == 0 ans[-1] ans -1 0 ans.append(0) ans.append ans append 0 u,v = edges[i] u edges[i] edges i v if uf.same(u,v):
      ans.append(ans[-1])
    else:
      w1,w2 = uf.weight(u), uf.weight(v)
      ans.append(ans[-1]-w1*w2)
      uf.union(u,v) uf.same(u,v) uf.same uf same u v ans.append(ans[-1]) ans.append ans append ans[-1] ans -1 w1,w2 = uf.weight(u), uf.weight(v) w1 uf.weight(u) uf.weight uf weight u w2 uf.weight(v) uf.weight uf weight v ans.append(ans[-1]-w1*w2) ans.append ans append ans[-1]-w1*w2 ans[-1] ans -1 w1*w2 w1 w2 uf.union(u,v) uf.union uf union u v for a in ans[::-1]:
  print(a) a ans[::-1] ans ::-1 -1 print(a) print a m = map(int,input().split()) map(int,input().split()) m w2 = uf.weight(u), uf.weight(v) uf.weight(v) w2 ans = [n*(n-1)//2] [n*(n-1)//2] ans v = edges[i] edges[i] v n,m = map(int,input().split()) map(int,input().split()) n uf = UF(n+1) UF(n+1) uf w1,w2 = uf.weight(u), uf.weight(v) uf.weight(u) w1 u,v = map(int,input().split()) map(int,input().split()) u u,v = edges[i] edges[i] u class UF():
  def __init__(self, N):
    self.parents = [-1] * N

  def find(self, n):
    if self.parents[n] < 0:
      return n
    else:
      self.parents[n] = self.find(self.parents[n])
      return self.parents[n]

  def union(self, u,v):
    p1,p2 = self.find(u),self.find(v)
    if p1==p2: return
    if p1 > p2:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

  def same(self, u,v):
    return self.find(u) == self.find(v)

  def weight(self, u):
    p = self.find(u)
    return -self.parents[p] class UF():
  def __init__(self, N):
    self.parents = [-1] * N

  def find(self, n):
    if self.parents[n] < 0:
      return n
    else:
      self.parents[n] = self.find(self.parents[n])
      return self.parents[n]

  def union(self, u,v):
    p1,p2 = self.find(u),self.find(v)
    if p1==p2: return
    if p1 > p2:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

  def same(self, u,v):
    return self.find(u) == self.find(v)

  def weight(self, u):
    p = self.find(u)
    return -self.parents[p] UF edges = [] [] edges v = map(int,input().split()) map(int,input().split()) v
class UF():
  def __init__(self, N):
    self.parents = [-1] * N

  def find(self, n):
    if self.parents[n] < 0:
      return n
    else:
      self.parents[n] = self.find(self.parents[n])
      return self.parents[n]

  def union(self, u,v):
    p1,p2 = self.find(u),self.find(v)
    if p1==p2: return
    if p1 > p2:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

  def same(self, u,v):
    return self.find(u) == self.find(v)

  def weight(self, u):
    p = self.find(u)
    return -self.parents[p]

n,m = map(int,input().split())
edges = []
for _ in range(m):
  u,v = map(int,input().split())
  edges.append((u,v))
edges.reverse()

uf = UF(n+1)

ans = [n*(n-1)//2]
for i in range(m-1):
  if ans[-1] == 0:
    ans.append(0)
  else:
    u,v = edges[i]
    if uf.same(u,v):
      ans.append(ans[-1])
    else:
      w1,w2 = uf.weight(u), uf.weight(v)
      ans.append(ans[-1]-w1*w2)
      uf.union(u,v)

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