#P6097. Bitwise OR and AND Convolution

    ID: 19320 Type: Default 1000ms 256MiB

Bitwise OR and AND Convolution

Bitwise OR and AND Convolution

You are given two sequences a0, a1, \(\ldots\), a2^n-1 and b0, b1, \(\ldots\), b2^n-1 of length \(2^n\). Your task is to compute a new sequence c0, c1, \(\ldots\), c2^n-1 such that for every \(0 \le k < 2^n\),

[ c_k = \sum_{\substack{i & j = 0 \ i \mid j = k}} a_i \cdot b_j \mod (10^9+9), ]

where \(i \& j = 0\) means the bitwise AND of \(i\) and \(j\) is zero and \(i \mid j = k\) means the bitwise OR of \(i\) and \(j\) equals \(k\). All arithmetic is performed modulo \(10^9+9\).

inputFormat

The first line contains an integer \(n\). The second line contains \(2^n\) integers representing the sequence \(a_0, a_1, \ldots, a_{2^n-1}\). The third line contains \(2^n\) integers representing the sequence \(b_0, b_1, \ldots, b_{2^n-1}\).

outputFormat

Output a single line containing \(2^n\) integers: \(c_0, c_1, \ldots, c_{2^n-1}\), separated by spaces. Each \(c_k\) is computed modulo \(10^9+9\).

sample

1
1 2
3 4
3 10