#include<iostream> #include <string> using namespace std; int main(void) { int T; long long K; long long n,m; cin >> T; while (T--) { cin >> K; n = 2; m = 1; while (K - n > 0) { K -= n; n <<= 1; ++m; } --K; string out(m,'4'); while (m--) { if (K&0x1) { out[m] = '7'; } K >>= 1; } cout << out << endl; } return 0; }