#P7457. [2017年杭电多校]Kanade's convolution

[2017年杭电多校]Kanade's convolution

Kanade's convolution

Problem Description

Give you two arrays A[0..2m1]A[0..2^m-1] and B[0..2m1]B[0..2^m-1]. Please calculate array C[0..2m1]C[0..2^m-1]£º

C[k]=i and j=kA[i xor j]B[i or j]C[k]=\sum_{i~and~j=k}A[i~xor~j]*B[i~or~j]

You just need to print i=02m1C[i]1526i mod 998244353\sum_{i=0}^{2^m-1}C[i]*1526^i ~mod~998244353 m<=19m<=19 0A[i],B[i]<9982443530\leq A[i],B[i]< 998244353

Input

There is only one test case. The first line consists of one integer mm. The second line consists of 2m2^m integers A[0..2m1]A[0..2^m-1] The third line consists of 2m2^m integers B[0..2m1]B[0..2^m-1]

Output

Output only one integer means the answer.

Sample Input

2
1 2 3 4
5 6 7 8

Sample Output

568535691

Source

2017 Multi-University Training Contest - Team 3

https://acm.hdu.edu.cn/showproblem.php?pid=6057