def find(i)
  if $parent[i]
    return find($parent[i])
  else
    return i
  end
end

n, m = gets.split.map(&:to_i)

bridges = m.times.map { gets.split.map(&:to_i) }
$parent = [nil] + Array.new(n, nil)
rank = [nil] + Array.new(n, 1)

ans = []
inconv = (n - 1) * n / 2
bridges.reverse_each do |x, y|
  ans << inconv
  xset = find(x)
  yset = find(y)
  if xset != yset
    inconv -= rank[xset] * rank[yset]

    if xset > yset
      xset, yset = yset, xset
    end
    $parent[xset] = yset
    rank[yset] += rank[xset]
  end
end

puts ans.reverse
