This page is still under construction.

Parts of this page are still being built. What you see may change.

Shuffle

Time limit1sMemory limit256 MB

Summary
Apply a recursive shuffle to a deck of 2^n cards t times and print the final card order.
Level

Medium7 of 10

Topics
Divide and conquer, Bit manipulation, Recursion, Implementation
Solved
No attempts yet

Problem

Byteasar has learnt a fabulous recursive method of shuffling a deck of cards. This algorithm can be described as follows:

  • In order to shuffle two cards, swap them.
  • In order to shuffle 2k2^k cards (k≥2k \geq 2), split them into two equal parts, an upper one and a lower one (so that each of them has 2k−12^{k - 1} cards). Shuffle each of them recursively and then put the lower half on the top of the upper half.

Byteasar has a deck of 2n2^n cards. Each of them has a number written on it. Byteasar now shuffles the deck, running the procedure described above exactly tt times. As it might take a great amount of time, he would like to know the final order of the cards beforehand.

Input

The first line of the input contains two integers n,tn, t (1≤n≤201 \le n \le 20, 1≤t≤1091 \le t \le 10^9). The second line contains 2n2^n integers a_1,…,a_2na\_1, \dots, a\_{2^n} (1≤a_i≤1091 \le a\_i \le 10^9); a_ia\_i is the number written on the ii-th topmost card in the deck.

Output

In the first and only line of output print 2n2^n integers, the numbers written on the cards of Byteasar's deck after tt shuffles. Print the numbers in the order from the topmost to the bottommost card.

Examples1

  1. Example 1

    Input
    2 1
    2 4 1 5
    
    Expected output
    5 1 4 2