
A team, X, is better than all the teams it has beaten, and it is worse than all the teams it has lost with. Moreover, we can apply a sort of transitivity: X is better than all the team that are worse than the teams that are worse than X; and X is worse than the teams that are better than the teams that are better than X. For example, in the case of N = 3, team 7 is worse than 6, 4 and 0.
When the competition is finished, all teams are given a ranking from 1 to 2N (different for each team, 1 for the winner, 2 for the subchampion, etc.). The ranking of team X is R(X). A valid ranking has the following property: if X is better than Y , then R(X) < R(Y ). Obviously, there are many possible valid rankings (because there are pairs of teams that we have no information between them). We define the optimistic classification of a team X as the smallest value of R(X) for any valid ranking R. Similarly, the pessimistic classification of X is the biggest value of R(X) for any valid ranking R.
Given the number of rounds, N , and the number of a team, X, you have to compute the optimistic and pessimistic classification of X.
The first line of the input contains an integer M , indicating the number of test cases. Each test case consists of two integers N and X. N is the total number of rounds in the competition (0 < N < 31), and X is the number of a team (0 ≤ X ≤ 2N − 1).
For each test case, the output should consist of a single line with two integers: the optimistic and the pessimistic classification of the corresponding team.