#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long PO(long long a, long long n) {
  long long val = 1;
  for (long long i = 0; i < n; i++) val *= a;
  return val;
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
signed main() {
  vector<long long> v;
  v.push_back(0);
  v.push_back(0);
  for (long long i = 2; i < 100 * 100 * 10; i++) {
    v.push_back((i * (i - 1)) / 2);
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    ;
    auto itr = lower_bound(v.begin(), v.end(), n);
    if (*itr == n) {
      long long val = itr - v.begin();
      cout << 1;
      for (long long j = 0; j < val; j++) cout << 3;
      cout << 7;
      cout << "\n";
    } else {
      map<long long, long long> ma;
      itr--;
      long long big = itr - v.begin();
      n -= (*itr);
      long long val = itr - v.begin();
      ma[val]++;
      while (n != 0) {
        itr = lower_bound(v.begin(), v.end(), n);
        if (*itr == n) {
          ma[(itr - v.begin())]++;
          break;
        } else {
          itr--;
          val = itr - v.begin();
          ma[val]++;
          n -= *itr;
        }
      }
      long long cnt = 0;
      cout << 1;
      for (long long i = 0; i < big; i++) {
        cout << 3;
        cnt++;
        if (ma[cnt]) {
          for (long long j = 0; j < ma[cnt]; j++) cout << 7;
        }
      }
      cout << "\n";
    }
  }
}
