P12737 [HackerEarth] lucky sequence
普及
题目描述

Lets call a string which is composed of only 4 and 7 a Lucky String. For example,
47, 444, 44744 are all Lucky Strings of length 2, 3 and 5 respectively, while 45, 767 are not Lucky Strings. Now, consider a sorted list of all the Lucky Strings that can be formed where the sorting is done by the following rule:
A string a comes before string b if either length(a) < length(b) or,
length(a)==length(b) and a comes lexicographically before b.
The first few elements in the list are as follows:
L = [ 4, 7, 44, 47, 74, 77, 444, 447, 474, 477, ....]

Now, given an index K, your objective is to print the K th element in the list L. Consider
1 based indexing.

Input:

The first line starts with a single integer T, the number of test cases.
T lines follow each containing a single integer K denoting an index of the list L.

Output:

Output T lines each containing the Lucky String at the K th index corresponding to each
test case.

Constraints:

1 ≤ T ≤ 100000
1 ≤ K ≤ 10^18

SAMPLE INPUT
3
1
5
11

SAMPLE OUTPUT
4
74
744

Explanation

It is easy to see that 1st and 5th element in the list are as in list given in the problem
statement. The 10th element in the list being 477, the next Lucky String is 744.

输入格式

见题面

输出格式

见题面

样例输入
3 1 5 11 SAMPLE
样例输出
4 74 744