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

  def root(self, i):
    if self.parent[i] < 0:
      return i
    r = self.root(self.parent[i])
    self.parent[i] = r
    return r

  def unite(self, i, j):
    i = self.root(i)
    j = self.root(j)
    if i == j:
      return
    if i > j:
      i, j = j, i
    self.parent[i] += self.parent[j]
    self.parent[j] = i

  def same(self, i, j):
    return self.root(i) == self.root(j)

  def size(self, i):
    return -self.parent[self.root(i)]

  def roots(self):
    return [self.root(i) for i in range(self.N)]

  def groupcount(self):
    return len(set(self.roots()))

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

edges = []
for _ in range(M):
  edges.append([int(e) - 1 for e in input().split()])

inconvenience =N*(N-1)//2
score=[]
for a, b in edges[::-1]:
  score.append(inconvenience)
  if not forest.same(a,b):
    inconvenience -= forest.size(a) * forest.size(b)
  forest.unite(a, b)

for s in score[::-1]:
  print(s) class UnionFind:
  def __init__(self, N):
    self.N = N
    self.parent = [-1] * N

  def root(self, i):
    if self.parent[i] < 0:
      return i
    r = self.root(self.parent[i])
    self.parent[i] = r
    return r

  def unite(self, i, j):
    i = self.root(i)
    j = self.root(j)
    if i == j:
      return
    if i > j:
      i, j = j, i
    self.parent[i] += self.parent[j]
    self.parent[j] = i

  def same(self, i, j):
    return self.root(i) == self.root(j)

  def size(self, i):
    return -self.parent[self.root(i)]

  def roots(self):
    return [self.root(i) for i in range(self.N)]

  def groupcount(self):
    return len(set(self.roots())) UnionFind def __init__(self, N):
    self.N = N
    self.parent = [-1] * N

   __init__ self.N = N self.N self N N self.parent = [-1] * N self.parent self parent [-1] * N [-1] -1 N self self N N def root(self, i):
    if self.parent[i] < 0:
      return i
    r = self.root(self.parent[i])
    self.parent[i] = r
    return r

   root if self.parent[i] < 0:
      return i
     self.parent[i] < 0 self.parent[i] self.parent self parent i 0 return i i r = self.root(self.parent[i]) r self.root(self.parent[i]) self.root self root self.parent[i] self.parent self parent i self.parent[i] = r self.parent[i] self.parent self parent i r return r r self self i i def unite(self, i, j):
    i = self.root(i)
    j = self.root(j)
    if i == j:
      return
    if i > j:
      i, j = j, i
    self.parent[i] += self.parent[j]
    self.parent[j] = i

   unite i = self.root(i) i self.root(i) self.root self root i j = self.root(j) j self.root(j) self.root self root j if i == j:
      return
     i == j i j return if i > j:
      i, j = j, i
     i > j i j i, j = j, i i j j i self.parent[i] += self.parent[j] self.parent[i] self.parent self parent i self.parent[j] self.parent self parent j self.parent[j] = i self.parent[j] self.parent self parent j i self self i i j j def same(self, i, j):
    return self.root(i) == self.root(j)

   same return self.root(i) == self.root(j) self.root(i) == self.root(j) self.root(i) self.root self root i self.root(j) self.root self root j self self i i j j def size(self, i):
    return -self.parent[self.root(i)]

   size return -self.parent[self.root(i)] -self.parent[self.root(i)] self.parent[self.root(i)] self.parent self parent self.root(i) self.root self root i self self i i def roots(self):
    return [self.root(i) for i in range(self.N)]

   roots self.root(i) for i in range(self.N) for i in range(self.N) i range(self.N) range self.N self N for i in range(self.N) self.root(i) self.root self root i return [self.root(i) for i in range(self.N)] [self.root(i) for i in range(self.N)] self self def groupcount(self):
    return len(set(self.roots())) groupcount return len(set(self.roots())) len(set(self.roots())) len set(self.roots()) set self.roots() self.roots self roots self self N, M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M forest = UnionFind(N) forest UnionFind(N) UnionFind N edges = [] edges [] for _ in range(M):
  edges.append([int(e) - 1 for e in input().split()]) _ range(M) range M int(e) - 1 for e in input().split() for e in input().split() e input().split() ().split () input split for e in input().split() int(e) - 1 int(e) int e 1 edges.append([int(e) - 1 for e in input().split()]) edges.append edges append [int(e) - 1 for e in input().split()] inconvenience =N*(N-1)//2 inconvenience N*(N-1)//2 N*(N-1) N N-1 N 1 2 score=[] score [] for a, b in edges[::-1]:
  score.append(inconvenience)
  if not forest.same(a,b):
    inconvenience -= forest.size(a) * forest.size(b)
  forest.unite(a, b) a b edges[::-1] edges ::-1 -1 score.append(inconvenience) score.append score append inconvenience if not forest.same(a,b):
    inconvenience -= forest.size(a) * forest.size(b)
   not forest.same(a,b) forest.same(a,b) forest.same forest same a b inconvenience -= forest.size(a) * forest.size(b) inconvenience forest.size(a) * forest.size(b) forest.size(a) forest.size forest size a forest.size(b) forest.size forest size b forest.unite(a, b) forest.unite forest unite a b for s in score[::-1]:
  print(s) s score[::-1] score ::-1 -1 print(s) print s score=[] [] score edges = [] [] edges inconvenience -= forest.size(a) * forest.size(b) forest.size(a) * forest.size(b) inconvenience class UnionFind:
  def __init__(self, N):
    self.N = N
    self.parent = [-1] * N

  def root(self, i):
    if self.parent[i] < 0:
      return i
    r = self.root(self.parent[i])
    self.parent[i] = r
    return r

  def unite(self, i, j):
    i = self.root(i)
    j = self.root(j)
    if i == j:
      return
    if i > j:
      i, j = j, i
    self.parent[i] += self.parent[j]
    self.parent[j] = i

  def same(self, i, j):
    return self.root(i) == self.root(j)

  def size(self, i):
    return -self.parent[self.root(i)]

  def roots(self):
    return [self.root(i) for i in range(self.N)]

  def groupcount(self):
    return len(set(self.roots())) class UnionFind:
  def __init__(self, N):
    self.N = N
    self.parent = [-1] * N

  def root(self, i):
    if self.parent[i] < 0:
      return i
    r = self.root(self.parent[i])
    self.parent[i] = r
    return r

  def unite(self, i, j):
    i = self.root(i)
    j = self.root(j)
    if i == j:
      return
    if i > j:
      i, j = j, i
    self.parent[i] += self.parent[j]
    self.parent[j] = i

  def same(self, i, j):
    return self.root(i) == self.root(j)

  def size(self, i):
    return -self.parent[self.root(i)]

  def roots(self):
    return [self.root(i) for i in range(self.N)]

  def groupcount(self):
    return len(set(self.roots())) UnionFind inconvenience =N*(N-1)//2 N*(N-1)//2 inconvenience forest = UnionFind(N) UnionFind(N) forest N, M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M
class UnionFind:
  def __init__(self, N):
    self.N = N
    self.parent = [-1] * N

  def root(self, i):
    if self.parent[i] < 0:
      return i
    r = self.root(self.parent[i])
    self.parent[i] = r
    return r

  def unite(self, i, j):
    i = self.root(i)
    j = self.root(j)
    if i == j:
      return
    if i > j:
      i, j = j, i
    self.parent[i] += self.parent[j]
    self.parent[j] = i

  def same(self, i, j):
    return self.root(i) == self.root(j)

  def size(self, i):
    return -self.parent[self.root(i)]

  def roots(self):
    return [self.root(i) for i in range(self.N)]

  def groupcount(self):
    return len(set(self.roots()))

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

edges = []
for _ in range(M):
  edges.append([int(e) - 1 for e in input().split()])

inconvenience =N*(N-1)//2
score=[]
for a, b in edges[::-1]:
  score.append(inconvenience)
  if not forest.same(a,b):
    inconvenience -= forest.size(a) * forest.size(b)
  forest.unite(a, b)

for s in score[::-1]:
  print(s)