Problem:
Score : 1600 points

Problem Statement

Snuke found a random number generator.
It generates an integer between 0 and 2^N-1 (inclusive).
An integer sequence A_0, A_1, \cdots, A_{2^N-1} represents the probability that each of these integers is generated. The integer i (0 \leq i \leq 2^N-1) is generated with probability A_i / S, where S = \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 X, which is now 0.
He can perform the following operation any number of times:

Generate an integer v with the generator and replace X with X \oplus v, where \oplus denotes the bitwise XOR.

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

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

Constraints

1 \leq N \leq 18

1 \leq A_i \leq 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_0 A_1 \cdots A_{2^N-1}

Output

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

Sample Input 1

2
1 1 1 1

Sample Output 1

0
4
4
4

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

Also, from any state, the value of X after one operation is 0, 1, 2 or 3 with equal probability.
Thus, the expected numbers of operations until X becomes 1, 2 and 3 are all 4.

Sample Input 2

2
1 2 1 2

Sample Output 2

0
499122180
4
499122180

The expected numbers of operations until X becomes 0, 1, 2 and 3 are 0, 7/2, 4 and 7/2, respectively.

Sample Input 3

4
337 780 799 10 796 875 331 223 941 67 148 483 390 565 116 355

Sample Output 3

0
468683018
635850749
96019779
657074071
24757563
745107950
665159588
551278361
143136064
557841197
185790407
988018173
247117461
129098626
789682908

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << (x) << endl;
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void wri(ll x){write(x),pc(' ');}
void writeln(ll x){write(x),pc('\n');}
const int maxn = 1e5+233;
ll mod=998244353;
ll qpow(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)ans=ans*a%mod;
	return ans;
}
ll inv2=(mod+1)/2;
int n,m;
ll p[maxn],a[maxn],b[maxn];
void fwt(ll a[]){
	for(int i=1;i<m;i<<=1){
		for(int j=0;j<m;j+=(i<<1)){
			for(int k=0;k<i;++k){
				ll x=a[j+k],y=a[j+k+i];
				a[j+k]=(x+y)%mod;
				a[j+k+i]=(x-y+mod)%mod;
			}
		}
	}
}
void ifwt(ll a[]){
	for(int i=1;i<m;i<<=1){
		for(int j=0;j<m;j+=(i<<1)){
			for(int k=0;k<i;++k){
				ll x=a[j+k],y=a[j+k+i];
				a[j+k]=(x+y)*inv2%mod;
				a[j+k+i]=(x-y+mod)*inv2%mod;
			}
		}
	}
}
int main(){
	n = read(),m = 1 << n;
	ll sum = 0;
	rep(i,0,m){
		p[i] = read();
		sum = (sum + p[i]) % mod;
	}sum = qpow(sum,mod-2);
	a[0] = m-1;rep(i,1,m) a[i] = mod - 1;
	rep(i,0,m) b[i] = p[i] * sum % mod;b[0] = (b[0]+mod-1)%mod;
	fwt(a);fwt(b);
	rep(i,0,m) a[i]=1ll*a[i]*qpow(b[i],mod-2)%mod;
	ifwt(a);
	rep(i,0,1<<n) writeln((a[i]-a[0]+mod)%mod);
	return 0;
}