#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const int MAXN = 1e5;
string s;
inline void solve(long long n) {
  long long sq = sqrt(n);
  long long now = sq * sq;
  if (n == sq * sq) {
    for (register int i = (1); i <= (sq); ++i) {
      s += '1';
    }
    s += "33";
    for (register int i = (1); i <= (sq); ++i) {
      s += '7';
    }
    return;
  }
  int mid = sq - 3, inv = 0;
  while (now + sq <= n) {
    now += sq, ++mid;
  }
  while (now < n) {
    ++now, ++inv;
  }
  s = "13";
  for (register int i = (1); i <= (mid); ++i) {
    s += '1';
  }
  s += '3';
  for (register int i = (1); i <= (inv); ++i) {
    s += '7';
  }
  s += '3';
  for (register int i = (1); i <= (sq); ++i) {
    s += '7';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    s.clear();
    if (n <= MAXN - 3) {
      while (n--) s += '1';
      s += "337";
    } else {
      solve(n);
    }
    cout << s << '\n';
  }
  return 0;
}
