A number is called faithful if you can write it as the sum of distinct powers of 7.
e.g., 2457 = 7 + 72 + 74
If we order all the faithful numbers, we get the sequence 1 = 70, 7 = 71, 8 = 70 + 71, 49 = 72, 50 = 70 + 72 . . . and so on.
Given some value of N, you have to find the N'th faithful number.
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of one line. The line consists of a positive integer N.
Corresponding to each test case, in a new line, print the value of the Nth faithful number
1 ≤ T ≤ 100
1 ≤ N ≤ 106
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.