N = gets.to_i
X = gets

def f(n)
  count = 0
  while n != 0
    popc = n.to_s(2).chars.select { |c| c == "1" }.count
    n %= popc
    count += 1
  end
  count
end

N.times.each do |i|
  x = X + "" # copy
  x[i] = x[i] == "1" ? "0" : "1"
  puts f(x.to_i(2))
end
