The chef was not happy with the binary number system, so he designed a new machine which is having 6 different states, i.e. in binary there is a total of 2 states as 0 and 1. Now, the chef is confused about how to correlate this machine to get an interaction with Integer numbers, when N(Integer number) is provided to the system, what will be the Nth number that system will return(in Integer form), help the chef to design this system.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow. 
- Each test case contains a single line of input, $N$. 
-----Output:-----
For each test case, output in a single line answer given by the system.
-----Constraints-----
- $1 \leq T \leq 10^5$
- $1 \leq N \leq 10^5$
-----Sample Input:-----
2
3
5
-----Sample Output:-----
7
37
-----EXPLANATION:-----
Initial numbers for system = [1, 6, 7, 36, 37, 42, 43, 216, …..
For 1) 3rd Number for the system will be 7.
For 2) 5th Number for the system will be 37.
import sys
# cook your dish here
T=int(input())
system=[0,1]
new_multiplier=1
while(len(system)<110000):
    new_multiplier*=6
    new_list=list( int(x+new_multiplier) for x in system)
    system+=new_list
for t in range(T):
    N=int(input())
    print(system[N])

import sys
# cook your dish here
T=int(input())
system=[0,1]
new_multiplier=1
while(len(system)<110000):
    new_multiplier*=6
    new_list=list( int(x+new_multiplier) for x in system)
    system+=new_list
for t in range(T):
    N=int(input())
    print(system[N])
