P10761 [HackerEarth] killing white walkers
普及
题目描述

"N" White Walkers are positioned in a circle from "1" to "N". First (No. 1) White Walker has a dragonglass . He kills the next White Walker (i.e. No. 2) and passes the dragonglass to the next (i.e. No. 3) who kills the 4th and passes the weapon to 5th White Walker. This way alternate killing of White Walkers goes on until only 1 survives. At what position is the survivor?

Assumption: Always the first White Walker starts to kill with the dragonglass.

Input
'T' No. of test cases.
'N' Total number of White Walkers in a circle .

Output
The position of the White Walker who survives.

Constraints:
1 ≤ N ≤ 10^5
1 ≤ T ≤ 100

SAMPLE INPUT
3
100
10
4

SAMPLE OUTPUT
73
5
1

输入格式

见题面

输出格式

见题面

样例输入
3 100 10 4 SAMPLE
样例输出
73 5 1