#AGC039C. [AGC039C] Division by Two with Something

[AGC039C] Division by Two with Something

Score : 800800 points

Problem Statement

Given are integers NN and XX. For each integer kk between 00 and XX (inclusive), find the answer to the following question, then compute the sum of all those answers, modulo 998244353998244353.

  • Let us repeat the following operation on the integer kk. Operation: if the integer is currently odd, subtract 11 from it and divide it by 22; otherwise, divide it by 22 and add 2N12^{N-1} to it. How many operations need to be performed until kk returns to its original value? (The answer is considered to be 00 if kk never returns to its original value.)

Constraints

  • 1N2×1051 \leq N \leq 2\times 10^5
  • 0X<2N0 \leq X < 2^N
  • XX is given in binary and has exactly NN digits. (In case XX has less than NN digits, it is given with leading zeroes.)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

XX

Output

Print the sum of the answers to the questions for the integers between 00 and XX (inclusive), modulo 998244353998244353.

3
111
40

For example, for k=3k=3, the operation changes kk as follows: 1,0,4,6,7,31,0,4,6,7,3. Therefore the answer for k=3k=3 is 66.

6
110101
616
30
001110011011011101010111011100
549320998