import sys
sys.setrecursionlimit(100000)
n,m = map(int,input().split())
def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x])

def unite(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 same(x,y):
  return find(x) == find(y)


par = [0]*n
for i in range(n):
  par[i] = i
rank = [1]*n
size = [1]*n

edge = [tuple(map(int,input().split())) for i in range(m)]
edge = edge[::-1]
for i in range(m):
  edge[i] = (edge[i][0]-1,edge[i][1]-1)

res = []
for i in range(m):
  fi = find(edge[i][0])
  se = find(edge[i][1])
  if fi == se:
    res.append(0)
  else:
    res.append(size[fi]*size[se])
    unite(fi,se)
  #print("rank:{}".format(rank))
  #print("size:{}".format(size))
  #print("par:{}".format(par))
  #print("res:{}".format(res))
  #print("======")
ass = 0
for i in range(m):
  ass += res[m-1-i]
  print(ass) import sys sys sys.setrecursionlimit(100000) sys.setrecursionlimit sys setrecursionlimit 100000 n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split 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 unite(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 unite 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 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 par = [0]*n par [0]*n [0] 0 n for i in range(n):
  par[i] = i i range(n) range n par[i] = i par[i] par i i rank = [1]*n rank [1]*n [1] 1 n size = [1]*n size [1]*n [1] 1 n tuple(map(int,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split edge = [tuple(map(int,input().split())) for i in range(m)] edge [tuple(map(int,input().split())) for i in range(m)] edge = edge[::-1] edge edge[::-1] edge ::-1 -1 for i in range(m):
  edge[i] = (edge[i][0]-1,edge[i][1]-1) i range(m) range m edge[i] = (edge[i][0]-1,edge[i][1]-1) edge[i] edge i (edge[i][0]-1,edge[i][1]-1) edge[i][0]-1 edge[i][0] [i] edge i 0 1 edge[i][1]-1 edge[i][1] [i] edge i 1 1 res = [] res [] for i in range(m):
  fi = find(edge[i][0])
  se = find(edge[i][1])
  if fi == se:
    res.append(0)
  else:
    res.append(size[fi]*size[se])
    unite(fi,se)
  #print("rank:{}".format(rank))
  #print("size:{}".format(size))
  #print("par:{}".format(par))
  #print("res:{}".format(res))
  #print("======") i range(m) range m fi = find(edge[i][0]) fi find(edge[i][0]) find edge[i][0] [i] edge i 0 se = find(edge[i][1]) se find(edge[i][1]) find edge[i][1] [i] edge i 1 if fi == se:
    res.append(0)
  else:
    res.append(size[fi]*size[se])
    unite(fi,se)
  #print("rank:{}".format(rank))
  #print("size:{}".format(size))
  #print("par:{}".format(par))
  #print("res:{}".format(res))
  #print("======") fi == se fi se res.append(0) res.append res append 0 res.append(size[fi]*size[se]) res.append res append size[fi]*size[se] size[fi] size fi size[se] size se unite(fi,se) unite fi se ass = 0 ass 0 for i in range(m):
  ass += res[m-1-i]
  print(ass) i range(m) range m ass += res[m-1-i] ass res[m-1-i] res m-1-i m-1 m 1 i print(ass) print ass size = [1]*n [1]*n size fi = find(edge[i][0]) find(edge[i][0]) fi m = map(int,input().split()) map(int,input().split()) m n,m = map(int,input().split()) map(int,input().split()) n def same(x,y):
  return find(x) == find(y) def same(x,y):
  return find(x) == find(y) same def unite(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 unite(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 unite 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 par = [0]*n [0]*n par rank = [1]*n [1]*n rank edge = edge[::-1] edge[::-1] edge ass += res[m-1-i] res[m-1-i] ass se = find(edge[i][1]) find(edge[i][1]) se edge = [tuple(map(int,input().split())) for i in range(m)] [tuple(map(int,input().split())) for i in range(m)] edge ass = 0 0 ass res = [] [] res
import sys
sys.setrecursionlimit(100000)
n,m = map(int,input().split())
def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x])

def unite(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 same(x,y):
  return find(x) == find(y)


par = [0]*n
for i in range(n):
  par[i] = i
rank = [1]*n
size = [1]*n

edge = [tuple(map(int,input().split())) for i in range(m)]
edge = edge[::-1]
for i in range(m):
  edge[i] = (edge[i][0]-1,edge[i][1]-1)

res = []
for i in range(m):
  fi = find(edge[i][0])
  se = find(edge[i][1])
  if fi == se:
    res.append(0)
  else:
    res.append(size[fi]*size[se])
    unite(fi,se)
  #print("rank:{}".format(rank))
  #print("size:{}".format(size))
  #print("par:{}".format(par))
  #print("res:{}".format(res))
  #print("======")
ass = 0
for i in range(m):
  ass += res[m-1-i]
  print(ass)