n, m = map(int, input().split())
par = [i for i in range(n)]
rank = [1] * n
size = [1] * n


ab = []
for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  ab.append([a,b])
'''
ab = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
'''
def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x])

def same(x, y):
  return find(x) == find(y)

def union(x, y):
  x = find(x)
  y = find(y)
  if x != y:
    if rank[x] < rank[y]:
      par[x] = y
      size[y] += size[x]
    else:
      par[y] = x
      size[x] += size[y]
      if rank[x] == rank[y]:
        rank[x] += 1


ans = [0 for i in range(m)]
# print (par,size,rank)
for i in range(m-1, -1, -1):
  x = find(ab[i][0])
  y = find(ab[i][1])
  if x != y:
    ans[i] = size[x] * size[y]
    union(x,y)
  # print(par,size,rank)
'''
print (ans)
print (par)
print (size)
print (rank)
'''
s = 0
for i in ans:
  s += i
  print (s) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i par = [i for i in range(n)] par [i for i in range(n)] rank = [1] * n rank [1] * n [1] 1 n size = [1] * n size [1] * n [1] 1 n ab = [] ab [] for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  ab.append([a,b]) 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 -= 1 a 1 b -= 1 b 1 ab.append([a,b]) ab.append ab append [a,b] a b '''
ab = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
''' def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x]) find if par[x] == x:
    return x
  else:
    return find(par[x]) par[x] == x par[x] par x x return x x return find(par[x]) find(par[x]) find par[x] par x x x def same(x, y):
  return find(x) == find(y) same return find(x) == find(y) find(x) == find(y) find(x) find x find(y) find y x x y y def union(x, y):
  x = find(x)
  y = find(y)
  if x != y:
    if rank[x] < rank[y]:
      par[x] = y
      size[y] += size[x]
    else:
      par[y] = x
      size[x] += size[y]
      if rank[x] == rank[y]:
        rank[x] += 1 union x = find(x) x find(x) find x y = find(y) y find(y) find y if x != y:
    if rank[x] < rank[y]:
      par[x] = y
      size[y] += size[x]
    else:
      par[y] = x
      size[x] += size[y]
      if rank[x] == rank[y]:
        rank[x] += 1 x != y x y if rank[x] < rank[y]:
      par[x] = y
      size[y] += size[x]
    else:
      par[y] = x
      size[x] += size[y]
      if rank[x] == rank[y]:
        rank[x] += 1 rank[x] < rank[y] rank[x] rank x rank[y] rank y par[x] = y par[x] par x y size[y] += size[x] size[y] size y size[x] size x par[y] = x par[y] par y x size[x] += size[y] size[x] size x size[y] size y if rank[x] == rank[y]:
        rank[x] += 1 rank[x] == rank[y] rank[x] rank x rank[y] rank y rank[x] += 1 rank[x] rank x 1 x x y y 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 ans = [0 for i in range(m)] ans [0 for i in range(m)] for i in range(m-1, -1, -1):
  x = find(ab[i][0])
  y = find(ab[i][1])
  if x != y:
    ans[i] = size[x] * size[y]
    union(x,y)
  # print(par,size,rank) i range(m-1, -1, -1) range m-1 m 1 -1 -1 x = find(ab[i][0]) x find(ab[i][0]) find ab[i][0] [i] ab i 0 y = find(ab[i][1]) y find(ab[i][1]) find ab[i][1] [i] ab i 1 if x != y:
    ans[i] = size[x] * size[y]
    union(x,y)
  # print(par,size,rank) x != y x y ans[i] = size[x] * size[y] ans[i] ans i size[x] * size[y] size[x] size x size[y] size y union(x,y) union x y '''
print (ans)
print (par)
print (size)
print (rank)
''' s = 0 s 0 for i in ans:
  s += i
  print (s) i ans s += i s i print (s) print s ab = [] [] ab y = find(ab[i][1]) find(ab[i][1]) y rank = [1] * n [1] * n rank def same(x, y):
  return find(x) == find(y) def same(x, y):
  return find(x) == find(y) same def union(x, y):
  x = find(x)
  y = find(y)
  if x != y:
    if rank[x] < rank[y]:
      par[x] = y
      size[y] += size[x]
    else:
      par[y] = x
      size[x] += size[y]
      if rank[x] == rank[y]:
        rank[x] += 1 def union(x, y):
  x = find(x)
  y = find(y)
  if x != y:
    if rank[x] < rank[y]:
      par[x] = y
      size[y] += size[x]
    else:
      par[y] = x
      size[x] += size[y]
      if rank[x] == rank[y]:
        rank[x] += 1 union par = [i for i in range(n)] [i for i in range(n)] par s += i i s def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x]) def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x]) find a, b = map(int, input().split()) map(int, input().split()) a b = map(int, input().split()) map(int, input().split()) b m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n a -= 1 1 a x = find(ab[i][0]) find(ab[i][0]) x ans = [0 for i in range(m)] [0 for i in range(m)] ans size = [1] * n [1] * n size b -= 1 1 b s = 0 0 s
n, m = map(int, input().split())
par = [i for i in range(n)]
rank = [1] * n
size = [1] * n


ab = []
for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  ab.append([a,b])
'''
ab = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
'''
def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x])

def same(x, y):
  return find(x) == find(y)

def union(x, y):
  x = find(x)
  y = find(y)
  if x != y:
    if rank[x] < rank[y]:
      par[x] = y
      size[y] += size[x]
    else:
      par[y] = x
      size[x] += size[y]
      if rank[x] == rank[y]:
        rank[x] += 1


ans = [0 for i in range(m)]
# print (par,size,rank)
for i in range(m-1, -1, -1):
  x = find(ab[i][0])
  y = find(ab[i][1])
  if x != y:
    ans[i] = size[x] * size[y]
    union(x,y)
  # print(par,size,rank)
'''
print (ans)
print (par)
print (size)
print (rank)
'''
s = 0
for i in ans:
  s += i
  print (s)
