Belarusian State University

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Being a student of Belarusian State University (BSU) is an earnest reason for pride. While studying the Theory of Algorithms course, you are obliged to solve many challenging problems before you are admitted to the final exam. Here is one of these problems.

You are given a positive integer nn and 4n4n integers c(i,j,k)c(i, j, k) which can be equal to 00 or 11 (0i<n0 \le i < n, j \in \left\\{0, 1\right\\}, k \in \left\\{0, 1\right\\}).

Consider two integers xx and yy between 00 and 2n12^n - 1, inclusively. Let x=_i=0n1x_i2ix = \sum\limits\_{i = 0}^{n - 1}{x\_i\cdot 2^i} and y=_i=0n1y_i2iy = \sum\limits\_{i = 0}^{n - 1}{y\_i \cdot 2^i} be their binary representations (x\_i, y\_j \in \left\\{0, 1\right\\}). Define f(x,y)=_i=0n1c(i,x_i,y_i)2if(x, y) = \sum\limits\_{i = 0}^{n - 1}{c(i, x\_i, y\_i)\cdot 2^i}. Clearly, f(x,y)f(x, y) is also an integer between 00 and 2n12^n - 1.

Given two multisets AA and BB, find the multiset of values f(a,b)f(a, b) over all pairs (a,b)(a, b), where aAa \in A, bBb \in B.

입력

The first line contains an integer nn (1n181 \leq n \leq 18).

The second line contains nn binary strings of 44 digits. The ii-th string consists of the values of c(i1,0,0)c(i - 1, 0, 0), c(i1,0,1)c(i - 1, 0, 1), c(i1,1,0)c(i - 1, 1, 0), c(i1,1,1)c(i - 1, 1, 1) in this particular order.

The next two lines describe multisets AA and BB, respectively. The description of a multiset consists of 2n2^n integers q_0,q_1,,q_2n1q\_0, q\_1, \ldots, q\_{2^n - 1} denoting the quantities of the numbers 0,1,,2n10, 1, \ldots, 2^n - 1 in the multiset (q_i0q\_i \ge 0, q_i109\sum q\_i \leq 10^9). There are no other numbers in the multisets.

출력

Print 2n2^n integers in a single line, the quantities of the numbers 0,1,,2n10, 1, \ldots, 2^n - 1 in the resulting multiset.

힌트

In the first example, you are given 55 and 66. For x\_i, y\_i \in \left\\{0, 1\right\\}, we have f(x_0+2x_1+4x_2,y_0+2y_1+4y_2)=(x_0 OR y_0)+2(x_1 XOR y_1)+4(x_2 AND y_2).f(x\_0 + 2x\_1 + 4x\_2, y\_0 + 2y\_1 + 4y\_2) = (x\_0 \text{ OR } y\_0) + 2 \cdot (x\_1 \text{ XOR } y\_1) + 4 \cdot (x\_2 \text{ AND } y\_2). Thus, the only number in the resulting multiset is 77.