NBIN - New Binary

One day Chandrima decided to make a list of all numbers starting from 1 in binary format, the list would be like 1, 10, 11, 100, ... and so on. Now she get bored of this list and decide to remove any pattern having at least two consecutive ones and prepare a new list. The new list will be like 1, 10, 100, 101, ... and so on. She then thought if a number n is given to her can she find the nth member of the new list. After trying for some time she comes to you for help. Can you help her by writing a program for her that coud do the specified task

Input

The first line contains T (<= 1000) test cases. The next T lines each contain one integer N (<= 10^15) for which you need to find the Nth member of the list.

Output

Output T lines each containing the required answer.

Example

Input:
3
1
2
3

Output:
1
10
100

Added by:Abhra
Date:2014-04-16
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2015-01-24 12:51:03 Petar Jesic
very interesting problem. Please note the output format.
2014-12-14 12:55:20 Vamsi Krishna Avula
good question, took a while but just 13 lines of code ;)

Last edit: 2014-12-14 12:56:48
2014-06-30 20:53:42 Pratham
my 100th.. :)
2014-06-27 15:10:51 sobriquet
Take care of long long and int. By far the most interesting problem.
2014-06-02 10:07:22 Ankit Paharia
very nice problem...
2014-05-31 08:55:15 P_Quantum
nice one!!
2014-05-14 07:00:54 kancha
nice problem :)

Last edit: 2014-05-14 07:10:43
2014-05-08 07:49:56 sarelfeniel
Nice problem.
2014-04-26 19:30:25 Gowtham Nagalingam
a good one
2014-04-25 10:45:31 Kanish_The_Vista
@venky thanks
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.