#AGC034F. [AGC034F] RNG and XOR

[AGC034F] RNG and XOR

Score : 16001600 points

Problem Statement

Snuke found a random number generator. It generates an integer between 00 and 2N12^N-1 (inclusive). An integer sequence A0,A1,,A2N1A_0, A_1, \cdots, A_{2^N-1} represents the probability that each of these integers is generated. The integer ii (0i2N10 \leq i \leq 2^N-1) is generated with probability Ai/SA_i / S, where S=i=02N1AiS = \sum_{i=0}^{2^N-1} A_i. The process of generating an integer is done independently each time the generator is executed.

Snuke has an integer XX, which is now 00. He can perform the following operation any number of times:

  • Generate an integer vv with the generator and replace XX with XvX \oplus v, where \oplus denotes the bitwise XOR.

For each integer ii (0i2N10 \leq i \leq 2^N-1), find the expected number of operations until XX becomes ii, and print it modulo 998244353998244353. More formally, represent the expected number of operations as an irreducible fraction P/QP/Q. Then, there exists a unique integer RR such that $R \times Q \equiv P \mod 998244353,\ 0 \leq R < 998244353$, so print this RR.

We can prove that, for every ii, the expected number of operations until XX becomes ii is a finite rational number, and its integer representation modulo 998244353998244353 can be defined.

Constraints

  • 1N181 \leq N \leq 18
  • 1Ai10001 \leq A_i \leq 1000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A0A_0 A1A_1 \cdots A2N1A_{2^N-1}

Output

Print 2N2^N lines. The (i+1)(i+1)-th line (0i2N10 \leq i \leq 2^N-1) should contain the expected number of operations until XX becomes ii, modulo 998244353998244353.

2
1 1 1 1
0
4
4
4

X=0X=0 after zero operations, so the expected number of operations until XX becomes 00 is 00.

Also, from any state, the value of XX after one operation is 00, 11, 22 or 33 with equal probability. Thus, the expected numbers of operations until XX becomes 11, 22 and 33 are all 44.

2
1 2 1 2
0
499122180
4
499122180

The expected numbers of operations until XX becomes 00, 11, 22 and 33 are 00, 7/27/2, 44 and 7/27/2, respectively.

4
337 780 799 10 796 875 331 223 941 67 148 483 390 565 116 355
0
468683018
635850749
96019779
657074071
24757563
745107950
665159588
551278361
143136064
557841197
185790407
988018173
247117461
129098626
789682908