F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Boring Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1243    Accepted Submission(s): 465


Problem Description
Given $n$ sheets of paper, place them on the table in pile and fold them in half $k$ times from left to right.

Now from top to bottom, mark a number on paper at each side of the front and back. So there are $2 \times n \times 2^k$ numbers in total and these numbers form a permutation $P$.

Now it expands to its original. These numbers from top to bottom, from front to back, from left to right form a permutation $Q$.

Given the permutation $P$, find the permutation $Q$.

See example for details.

For $k=1$ and $P=1..4 \times n$, you can assume that you are marking the page numbers before printing a booklet forming from $n$ pieces of $A4$ papers.
 

Input
The first line contains a single integer $T(1 \leq T \leq 30)$ , the number of test cases.

For each test case, the first line gives two integers $n$, $k$($1 \leq n \leq 200, 1 \leq k \leq 10$).

The next line gives the permutation $P$ that consists of $2 \times n \times 2^k$ integers $p_i(1 \leq p_i \leq 2 \times n \times 2^k)$.

It is guaranteed that $ \sum 2 \times n \times 2^k$ doesn't exceed $10^6$.
 

Output
The output should contain $T$ lines each containing $2 \times n \times 2^k$ integers separated by spaces, indicating the permutation $Q$.
 

Sample Input
1 2 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
 

Sample Output
12 5 4 13 11 6 3 14 10 7 2 15 9 8 1 16 [hint] [center][img]../../data/images/C883-1003-1.png[/img][/center] [\hint]
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-24 18:09:23, Gzip enabled