output_description: Print N lines. The i-th line should contain the value f(X_i).
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      X
attempt: import sys
  
  sys.setrecursionlimit(10**6)  # 再帰関数の再帰の深さを設定
  to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
  print_list_in_2D = lambda x: print(
      *x, sep="\n"
  )  # リストの要素を改行を挟んで表示する関数
  
  
  # 入力を整数に変換して受け取る
  def input_int():
      return int(input())
  
  
  def map_int_input():
      return map(int, input())
  
  
  MII = map_int_input
  
  
  def MII_split():
      return map(int, input().split())
  
  
  def MII_to_index():
      return map(to_index, input())
  
  
  def MII_split_to_index():
      return map(to_index, input().split())
  
  
  # 入力全てを整数に変換したものの配列を受け取る
  def list_int_inputs():
      return list(map(int, input()))
  
  
  LII = list_int_inputs
  
  
  def LII_split():
      return list(map(int, input().split()))
  
  
  # 2次元リスト化
  def LII_2D(rows_number):
      return [LII() for _ in range(rows_number)]
  
  
  def LII_split_2D(rows_number):
      return [LII_split() for _ in range(rows_number)]
  
  
  N = input_int()
  X = input()
  X = int(X, 2)
  
  for i in range(1, N + 1):
      tmp = 1 << N - i
      X_i = X ^ tmp
      # print(f'{X_i=}')
  
      popcount = bin(X_i).count("1")
      it_num = X_i // popcount
      ans = 1
      for j in range(it_num):
          X_i = X_i % popcount
          if X_i == 0:
              break
          popcount = bin(X_i).count("1")
          ans += 1
      print(ans)
  
problem_description: Statement
  
  Let \mathrm{popcount}(n) be the number of `1`s in the binary representation of
  n. For example, \mathrm{popcount}(3) = 2, \mathrm{popcount}(7) = 3, and
  \mathrm{popcount}(0) = 0.
  
  Let f(n) be the number of times the following operation will be done when we
  repeat it until n becomes 0: "replace n with the remainder when n is divided
  by \mathrm{popcount}(n)." (It can be proved that, under the constraints of
  this problem, n always becomes 0 after a finite number of operations.)
  
  For example, when n=7, it becomes 0 after two operations, as follows:
  
    * \mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.
    * \mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.
  
  You are given an integer X with N digits in binary. For each integer i such
  that 1 \leq i \leq N, let X_i be what X becomes when the i-th bit from the top
  is inverted. Find f(X_1), f(X_2), \ldots, f(X_N).
samples: [{"input": "3\n    011", "output": "2\n    1\n    1\n    \n\n  * X_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n  * X_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n  * X_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\n* * *"}, {"input": "23\n    00110111001011011001110", "output": "2\n    1\n    2\n    2\n    1\n    2\n    2\n    2\n    2\n    2\n    2\n    2\n    2\n    2\n    2\n    2\n    2\n    2\n    2\n    2\n    2\n    1\n    3"}]