#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int inf = 0x3f3f3f3f;
constexpr ll MOD = 1000000007LL;
constexpr double tol = 1e-8;
inline ll powmod(ll a, ll b, ll mod = MOD) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
  }
  return res;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  vector<long long> nums;
  ll st = 0;
  for (int(i) = (1); (i) < (1e5); ++(i)) {
    st += i;
    nums.push_back(st);
  }
  int t;
  cin >> t;
  for (int(i) = (0); (i) < (t); ++(i)) {
    ll val;
    cin >> val;
    vector<pair<int, int> > bora;
    while (val > 0) {
      auto it = upper_bound((nums).begin(), (nums).end(), val);
      --it;
      int idx = it - nums.begin();
      bora.emplace_back(idx, *it);
      val -= (*it);
    }
    string ans;
    sort((bora).begin(), (bora).end());
    ans += '1';
    int total_3 = 0;
    for (const auto& x : bora) {
      while (total_3 != x.first + 2) {
        ans += '3';
        total_3++;
      }
      ans += '7';
    }
    cout << ans << endl;
  }
  return 0;
}
