Under construction

Still being built. Things may change

Trans

Time limit2sMemory limit512 MB

Summary
Given an array a of 2^n integers, compute for each i the sum of a_j over all j where popcount(i and j) is odd.
Level

Medium5 of 10

Topics
Bit manipulation, Divide and conquer
Solved
No attempts yet

Statement

Bob is interested in popcount and some strange transforms. Currently, he is attacking the following problem:

There is an array of 2n2^n integers a0,a1,a2,…,a2n−1a_0,a_1,a_2,\ldots,a_{2^n-1}. For each ii (0≤i≤2n−10 \le i \le 2^n-1), calculate

bi=∑j=02n−1(popcount⁡(iand⁡j) mod 2)⋅ajb_i=\sum_{j=0}^{2^n-1} (\operatorname{popcount}(i \operatorname{and} j) \bmod 2) \cdot a_j

where popcount⁡(x)\operatorname{popcount}(x) denotes the number of ones in the binary representation of xx, and and⁡\operatorname{and} denotes the bitwise AND operation.

Although Bob is very smart, he still can't solve the problem fast. Can you help him calculate all bib_i?

Input

The first line contains a single integer nn (1≤n≤201 \le n \le 20).

The second line contains 2n2^n integers describing the array aa (1≤ai≤1091 \le a_i \le 10^9).

Output

Print one line with 2n2^n integers, the ii-th of them being the value bib_i.

Examples1

  1. Example 1

    Input
    2
    1 2 3 4
    
    Expected output
    0 6 7 5