A complete binary tree is made of nodes arranged in a hierarchical structure. One of the nodes is the root node, said to be at level . The root node has two child nodes, which are at level . Each of those has two children at level etc.
In general, a complete binary tree with levels has nodes, each of which has two child nodes, except those at level .
A number can be written into each node. Write the numbers to into a complete binary tree with levels so that, for each node at level , the absolute value of the difference of the sum of all numbers in the left subtree and the sum of all numbers in the right subtree is .
For example, the sum of the left subtree of the root node must differ from the sum of the right subtree by . The sums of the left and right subtrees of a node at level must differ by .
Each number must be used exactly once. The solution need not be unique.
Input Specification
The first and only line of input contains the integer , the number of levels in the tree.
Output Specification
Output the integers separated by spaces on a single line, the binary tree in the preorder traversal. The preorder traversal first outputs the number in the root node, then outputs the left subtree (again in the preorder traversal), then the right subtree.
Sample Input 1
2
Sample Output 1
3 1 2
Sample Input 2
3
Sample Output 2
3 1 7 5 6 2 4
Comments