local n, m = io.read("*n", "*n")
local as, bs = {}, {}
local parent = {}
local sz = {}
for i = 1, n do
  parent[i] = i
  sz[i] = 1
end
local ret = n * (n - 1) // 2
for i = 1, m do
  as[i], bs[i] = io.read("*n", "*n")
end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end
local ans = {}
for i = 1, m do
  ans[i] = 0
end
for i = m, 1, -1 do
  ans[i] = ret
  local a, b = as[i], bs[i]
  local ra, rb = uf_findroot(a), uf_findroot(b)
  if ra ~= rb then
    local sza, szb = sz[ra], sz[rb]
    ret = ret - sza * szb
    sz[ra] = sza + szb
    parent[rb], parent[b] = ra, ra
  end
end
print(table.concat(ans, "\n"))
