Grundy's game
Longing, loneliness, pain, the breath of night – This, of course, is not at all what you want Flёur
Vasya is passionate about the game of Grundy. Unfortunately, Vasya doesn't have anyone to play with, and he isn't concerned about winning or losing. His sole interest lies in determining the Grundy numbers for various piles in the game. Day and night, he dedicates himself to calculating these numbers. It would be unkind not to assist Vasya in completing his calculations swiftly, so he can move on to finding a job, a girlfriend, or perhaps the meaning of life.
Let's revisit the rules of the Grundy game. Initially, there is a single pile of stones. During each turn, a player selects an existing pile and splits it into two non-empty piles, ensuring the two new piles are of different sizes. The player who cannot make a move loses the game.
Input
The first line contains the number N (1 ≤ N ≤ 10^4) – the number of queries. Following this, there are N lines, each containing a single number b_i (1 ≤ b_i ≤ 10^4), representing the size of the next pile.
Output
For each query, output the Grundy number of the corresponding pile on a new line.