Two friends Gautam and Shubham, after attending weekend GeeksClasses, have planned to go for Padmavat Movie. There they find the soldiers getting killed during war. After the movie, Gautam decided to play a game of “KHALIBALI” in which there are N soldiers with numbers on them. The numbers follow a series as 3, 9, 12, 27... and so on . Shubham has to guess a number N and soldier with Nth number of series on will be killed. Now, help Shubham in finding the soldier to be killed.
Input : First line of input contains number of testcases T. For each testcase, there will be a single positive integer N.
Ouput : For each testcase, you need to print number on Nth soldier.
1 <= T <= 100
1 <= N <= 106