We all know that "Lord" Prajwal is the best coder of the pre-final year in NIT Jamshedpur. As a result he is popular among girls. He has mobile numbers of n girls. Being the geek he is, he decides to store all those mobile numbers in an n-ary tree. The numbers are weird ones as well. The number of 0th girl is 0, 1st girl is 1 and so on. The tree is structured like this . The parent of nth child is obtained by converting the number into binary and then setting the least significant 1 to 0. For example, the parent of 3 is 2 because binary of 3 is 11 and setting least significant 1 to 0, we get 10 which is the binary representation of 2.
So given t test cases and a number n for each test case, you have to print the maximum distance between two nodes of the tree.
Input format:
A number T followed by T lines each representing a number N
Output format:
For each test case, print the required answer on a new line.
Constraints:
1≤T≤100
1≤N≤106
For test case 1 n=4, node 0 is root, parent of:
1 is 0,
2 is 1,
3 is 2, and
4 is 0 .
Therefore maximum distance exists between nodes valued 3 and 4 , (or 1 and 3) which is equal to 3 .
Author: Ayush Dubey