#aising2020d. [aising2020_d]Anything Goes to Zero

[aising2020_d]Anything Goes to Zero

Problem Statement

Let mathrmpopcount(n)\\mathrm{popcount}(n) be the number of 1s in the binary representation of nn. For example, mathrmpopcount(3)=2\\mathrm{popcount}(3) = 2, mathrmpopcount(7)=3\\mathrm{popcount}(7) = 3, and mathrmpopcount(0)=0\\mathrm{popcount}(0) = 0.

Let f(n)f(n) be the number of times the following operation will be done when we repeat it until nn becomes 00: "replace nn with the remainder when nn is divided by mathrmpopcount(n)\\mathrm{popcount}(n)." (It can be proved that, under the constraints of this problem, nn always becomes 00 after a finite number of operations.)

For example, when n=7n=7, it becomes 00 after two operations, as follows:

  • mathrmpopcount(7)=3\\mathrm{popcount}(7)=3, so we divide 77 by 33 and replace it with the remainder, 11.
  • mathrmpopcount(1)=1\\mathrm{popcount}(1)=1, so we divide 11 by 11 and replace it with the remainder, 00.

You are given an integer XX with NN digits in binary. For each integer ii such that 1leqileqN1 \\leq i \\leq N, let XiX_i be what XX becomes when the ii-th bit from the top is inverted. Find f(X1),f(X2),ldots,f(XN)f(X_1), f(X_2), \\ldots, f(X_N).

Constraints

  • 1leqNleq2times1051 \\leq N \\leq 2 \\times 10^5
  • XX is an integer with NN digits in binary, possibly with leading zeros.

Input

Input is given from Standard Input in the following format:

NN XX

Output

Print NN lines. The ii-th line should contain the value f(Xi)f(X_i).


Sample Input 1

3
011

Sample Output 1

2
1
1
  • X1=7X_1 = 7, which will change as follows: 7rightarrow1rightarrow07 \\rightarrow 1 \\rightarrow 0. Thus, f(7)=2f(7) = 2.
  • X2=1X_2 = 1, which will change as follows: 1rightarrow01 \\rightarrow 0. Thus, f(1)=1f(1) = 1.
  • X3=2X_3 = 2, which will change as follows: 2rightarrow02 \\rightarrow 0. Thus, f(2)=1f(2) = 1.

Sample Input 2

23
00110111001011011001110

Sample Output 2

2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
3