local ior = io.input()
local n, m = ior:read("*n", "*n")
local as, bs = {}, {}
for i = 1, m do
  as[i], bs[i] = ior:read("*n", "*n")
end

local parent = {}
local rootlist = {}
local score = {}
for i = 1, n do parent[i], score[i] = 0, 0 end

local function getroot(idx)
  while(parent[idx] ~= 0) do
    idx = parent[idx]
  end
  return idx
end

score[m] = 0
for i = m, 2, -1 do
  local sc = 0
  local a, b = as[i], bs[i]
  local ar, br = getroot(a), getroot(b)
  if(ar ~= a) then parent[a] = ar end
  if(br ~= b) then parent[b] = br end
  if(ar == br) then
    -- nothing
  elseif(ar == a and br == b) then
    parent[b] = a
    if(rootlist[b] == nil) then
      if(rootlist[a] == nil) then rootlist[a], sc = 2, 1
      else
        sc = rootlist[a]
        rootlist[a] = sc + 1
      end
    else
      if(rootlist[a] == nil) then
        sc = rootlist[b]
        rootlist[a] = sc + 1
      else
        local tmp1, tmp2 = rootlist[a], rootlist[b]
        sc = ((tmp1 + tmp2) * (tmp1 + tmp2 - 1) - tmp1 * (tmp1 - 1) - tmp2 * (tmp2 - 1)) / 2
        rootlist[a] = tmp1 + tmp2
      end
      rootlist[b] = nil
    end
  elseif(ar == a) then
    parent[a] = br
    if(rootlist[a] == nil) then
      sc = rootlist[br]
      rootlist[br] = sc + 1
    else
      local tmp1, tmp2 = rootlist[br], rootlist[a]
      sc = ((tmp1 + tmp2) * (tmp1 + tmp2 - 1) - tmp1 * (tmp1 - 1) - tmp2 * (tmp2 - 1)) / 2
      rootlist[br] = tmp1 + tmp2
      rootlist[a] = nil
    end
  elseif(br == b) then
    parent[b] = ar
    if(rootlist[b] == nil) then
      sc = rootlist[ar]
      rootlist[ar] = sc + 1
    else
      local tmp1, tmp2 = rootlist[ar], rootlist[b]
      sc = ((tmp1 + tmp2) * (tmp1 + tmp2 - 1) - tmp1 * (tmp1 - 1) - tmp2 * (tmp2 - 1)) / 2
      rootlist[ar] = tmp1 + tmp2
      rootlist[b] = nil
    end
  elseif(ar ~= br) then
    parent[br] = ar
    local tmp1, tmp2 = rootlist[ar], rootlist[br]
    sc = ((tmp1 + tmp2) * (tmp1 + tmp2 - 1) - tmp1 * (tmp1 - 1) - tmp2 * (tmp2 - 1)) / 2
    rootlist[ar] = tmp1 + tmp2
    rootlist[br] = nil
  end
  score[i - 1] = score[i] + sc
end
local mx = n * (n - 1) / 2
for i = 1, m do
  print(mx - score[i])
end
