#include <bits/stdc++.h>
using namespace std;
inline uint64_t modpow(uint64_t base, uint64_t exp, uint64_t modulus) {
  base %= modulus;
  uint64_t result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
inline uint64_t modinv(uint64_t x, uint64_t mod) {
  return modpow(x, mod - 2, mod);
}
uint64_t fak[100100];
void precomp() {
  fak[0] = fak[1] = 1;
  for (int i = 2; i < 100100; i++) {
    fak[i] = i * fak[i - 1];
    fak[i] %= 998244353;
  }
}
inline uint64_t nCr(uint64_t n, uint64_t r) {
  if (n < r) return 0;
  uint64_t res = fak[n] * modinv(fak[r], 998244353);
  res %= 998244353;
  res *= modinv(fak[n - r], 998244353);
  res %= 998244353;
  return res;
}
vector<int64_t> factors(int64_t x) {
  vector<int64_t> fac;
  for (int64_t i = 1; i <= int64_t(sqrt(x)); i++) {
    if (x % i == 0) {
      fac.push_back(i);
    }
  }
  return fac;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  precomp();
  int t;
  cin >> t;
  while (t--) {
    int64_t n;
    cin >> n;
    vector<int64_t> fac = factors(n);
    if (fac.back() + n / fac.back() <= 100000 - 2) {
      cout << string(fac.back(), '1') << 33 << string(n / fac.back(), '7')
           << endl;
      continue;
    } else {
      for (int64_t threes = 2;; threes++) {
        int64_t threesC2 = nCr(threes, 2);
        int64_t threes2C2 = nCr(threes + 2, 2);
        fac = factors(n - threesC2);
        if (fac.back() + n / fac.back() <= 100000 - 100) {
          int64_t ones = n / fac.back() - threes2C2;
          int64_t sevens = fac.back();
          if (ones < 0) continue;
          cout << 1 << string(threes, '3') << 7 << string(ones, '1') << "33"
               << string(sevens, '7') << endl;
          break;
        }
      }
    }
  }
  return 0;
}
