There are k balls from one complete binary tree (fully binary TREE,FBT) root (root) down one by one. When the ball encounters a non-terminal node, it may run toward the left subtree, or to the right subtree, until the ball reaches the end node (that is, the leaves). The decision to turn the ball to the left or right at a non-terminal node is controlled by a 2-value true,false. If the current value of this non-terminal node is false, the ball will go to the left subtree when it comes, but this value will become true. If the current value of this non-endpoint is true, the ball will go to the right subtree when it comes, but this value will change to false. Note: At the beginning, all non-endpoint values are false. In addition, all nodes in the complete binary tree are sequentially numbered, from top (depth = 1) to bottom, left to right. Please refer to.
For example, the above figure is a full binary tree with a depth of 4. The first ball falls down and goes through nodes 1, 2, 4, and finally in node 8. The second ball goes down and then it goes through nodes 1, 3, and 6 and finally falls in node 12. The third ball goes down. Nodes 1, 2, and 5 finally fall in node 10.
Give you the depth of the full binary tree D as well as the falling ball of the first I, please write a program to calculate the number of the I-ball falling on the terminal node.
Input
The first column of the input has an integer that represents the following set of test data.
Each set of test data is listed with 2 integers d,i (2 <= D <= 20,1 <= I <= 524288). You can assume that I will not exceed the number of end nodes.
Output
For each set of test data output a column, the I ball falls on the end node number.
6_6 ball Drop (UVa679) < full binary tree numbering >