#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 5;
const long long int mod = 1e9 + 7;
const long long int inf = 1e9 + 9;
long long int a[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t, n, c = 0;
  cin >> t;
  for (c = 1;; c++) {
    a[c] = c * (c - 1) / 2;
    if (a[c] > mod) break;
  }
  while (t--) {
    string s = "";
    cin >> n;
    vector<long long int> v;
    for (long long int i = c; i >= 3; i--) {
      if (a[i] <= n) {
        v.push_back(i);
        n -= a[i];
      }
    }
    reverse(v.begin(), v.end());
    long long int j = 0;
    s = "1";
    if (n == 2)
      s += "3377", j = 2;
    else if (n == 1) {
      s += "337", j = 2;
    }
    for (long long int i : v) {
      for (; j < i; j++) s.push_back('3');
      s.push_back('7');
    }
    cout << s << '\n';
  }
  return 0;
}
