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

local function getscore()
  local sc = 0
  for k, v in pairs(rootlist) do
    sc = sc + v * (v - 1) / 2
  end
  return sc
end

for i = m, 1, -1 do
  score[i] = getscore()
  if(i == 1) then break end
  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
      rootlist[a] = 2
    else
      rootlist[a] = 1 + rootlist[b]
      rootlist[b] = nil
    end
  elseif(ar == a) then
    parent[a] = br
    if(rootlist[a] == nil) then
      rootlist[br] = rootlist[br] + 1
    else
      rootlist[br] = rootlist[br] + rootlist[a]
      rootlist[a] = nil
    end
  elseif(br == b) then
    parent[b] = ar
    if(rootlist[b] == nil) then
      rootlist[ar] = rootlist[ar] + 1
    else
      rootlist[ar] = rootlist[ar] + rootlist[b]
      rootlist[b] = nil
    end
  elseif(ar ~= br) then
    parent[br] = ar
    rootlist[ar] = rootlist[ar] + rootlist[br]
    rootlist[br] = nil
  end
end
local mx = n * (n - 1) / 2
for i = 1, m do
  print(mx - score[i])
end
