LUCKYN  Lucky Numbers
Shrek and Kung Fu Panda once met after having no forthcoming prequels. They quickly noticed that both of them were superstitious and this helped them bond a lot.
Shrek believes that the number 4 is lucky and Kung Fu Panda believes that number 7 is lucky. You being their friend want to list down numbers in increasing order that consist only of 4 or 7.
The first few elements of the list are 4, 7, 44, 47, 74, 77, 444 ... You must answer the nth (1based, 4 is the 1st term of the sequence)
Input
The first line contains the number of testcases T
The following Tlines contains an integer n.
T <= 10,000
n <= 1000,000,000
Output
Print the nth term in the sequence of lucky numbers
Example
Input: 6 1 20 300 4000 50000 1000000000 Output: 4 4747 44747747 77774744447 744447747474447 77477744774747744747444444447
hide comments
nadstratosfer:
20180617 07:39:46
Enjoyed figuring this out. 

Siya:
20141110 10:25:54
Can you provide any tricky test cases because i have checked almost all manually and finding my solution correct


Naveen Kumar:
20121005 06:03:10
i m getting wrong answer, why?

Added by:  .:: Pratik ::. 
Date:  20110307 
Time limit:  1.528s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 