Xorstanta

Time limit: 0.3s Memory limit: 256MB Input: Output:

A long time ago in 2018, the National Olympiad in Informatics was held in the city of Constanta. Every contestant was deeply upset that none of the tasks in the problem set was named Xorstanta.

You are given a number NN. You also have two variables a=0a = 0 and b=0b = 0 and for each number ii from 11 to NN you have to choose between a=aia = a \oplus i and b=bib = b \oplus i. Output the largest value for a+ba + b possible given the number NN.

\oplus represents the bitwise XOR operation.

Input

The first line contains the number of tests you have to solve, TT (1T1051 \leq T \leq 10^5).
For each test you have a line containing the number NN (1N1091 \leq N \leq 10^9).

For tests worth 10%10\% of the points, 1N201 \leq N \leq 20 and T=1T = 1.
For tests worth extra 20%20\% of the points, 1N1051 \leq N \leq 10^5 and T=1T = 1.

Output

Each line contains the solution to the test you are solving.

Example

stdin

4
6
30
15
18

stdout

7
31
30
43

Log in or sign up to be able to send submissions!