#P10553. Binary Tree ID Discovery

    ID: 12573 Type: Default 1000ms 256MiB

Binary Tree ID Discovery

Binary Tree ID Discovery

You are given a full binary tree with \(n\) levels (so it has exactly \(2^n-1\) nodes). Each node has an integer ID from \(1\) to \(2^n-1\), and these IDs form a permutation of \(\{1,2,\dots,2^n-1\}\). However, the arrangement of the IDs is hidden.

Your task is to determine the IDs of all the nodes. Although the original problem statement mentions using at most 4800 queries, in this problem you are provided with the entire permutation as input. Simply output the permutation as it is given.

inputFormat

The first line contains an integer (n) ((1 \le n \le 10), for example), representing the number of levels of the full binary tree. The next line contains (2^n-1) integers, which are the IDs of the nodes in level-order.

outputFormat

Output the (2^n-1) integers in one line separated by spaces, which represent the IDs of the nodes in the same order as given in the input.

sample

2
1 2 3
1 2 3