#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream& operator<<(ostream& out, const pair<A, B>& a) {
  return out << "(" << a.first << ", " << a.second << ")";
}
template <class A>
ostream& operator<<(ostream& out, const vector<A>& v) {
  out << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) out << ", ";
    out << v[i];
  }
  return out << "]";
}
void solve() {
  long long n;
  cin >> n;
  for (int i = 200; i >= 0; i--) {
    long long x = (i * (i - 1)) / 2;
    long long y = n / x;
    if (y == 0) {
      continue;
    }
    long long rem = n - x * y;
    string res;
    res += '7';
    for (int j = 1; j <= i; j++) {
      res += '3';
      if (j == 2) {
        for (int k = 0; k < rem; k++) {
          res += '1';
        }
      }
    }
    for (int j = 0; j < y; j++) res += '1';
    reverse(res.begin(), res.end());
    cout << res << '\n';
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q = 1;
  cin >> q;
  for (int kase = 1; kase <= q; kase++) {
    solve();
  }
  return 0;
}
