Complete Binary Tree

No attempts yetTime limit1sMemory limit128 MB

Problem

Sanggeun is travelling in Donji Andrijevci, a town in Slovenia. The streets of the town form a complete binary tree of depth KK. A complete binary tree of depth KK has 2K12^K - 1 nodes. Every node carries the number of the building that stands there, and every node outside the last level has one left child and one right child.

Complete binary trees of depth 2 and depth 3

Sanggeun entered every building in the town and wrote the numbers on a sheet of paper in the order he entered them. Back in Korea he tried to draw the town, but he could not remember its shape. He did remember the order in which he walked around.

  1. Sanggeun starts in front of the building at the root of the tree.
  2. If he has not entered the building at the left child of the current node, he moves to the left child.
  3. If the current node has no left child, or he already entered the building at the left child, he enters the building at the current node and writes its number on the paper.
  4. If he already entered the current building and the node has a right child, he moves to the right child.
  5. If he already visited the current building and the buildings at both children, he moves to the parent node.

For the tree on the left in the picture Sanggeun entered the buildings in the order 2, 1, 3, and for the tree on the right the order is 1, 6, 4, 3, 5, 2, 7. Given the whole order Sanggeun wrote down, write a program that finds the building numbers on each level.

Input

The first line contains KK (1K101 \le K \le 10).

The second line contains the 2K12^K - 1 building numbers in the order Sanggeun entered them, separated by spaces. The numbers are distinct and all of them lie in the interval [1,2K)[1, 2^K).

Output

Print the answer on KK lines. On line ii print the numbers of the buildings on level ii from left to right, separated by single spaces.