#include <bits/stdc++.h>
using namespace std;
long long arr1[100005];
int cnt[100005];
void cut(int n) {
  while (n) {
    int x = upper_bound(arr1 + 1, arr1 + 100001, n) - arr1 - 1;
    cnt[x]++;
    n -= arr1[x];
  }
}
int huaji[100005];
int main() {
  for (long long i = 1; i <= 100000; i++) arr1[i] = i * (i - 1) / 2;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= 100000; i++) cnt[i] = 0;
    cut(n);
    int last = 0;
    int siz = 0;
    for (int i = 1; i <= 100000; i++) {
      if (cnt[i]) {
        for (int u = 1; u <= i - last; u++) huaji[++siz] = 3;
        for (int u = 1; u <= cnt[i]; u++) huaji[++siz] = 1;
        last = i;
      }
    }
    for (int i = siz; i >= 1; i--) putchar('0' + huaji[i]);
    putchar('7');
    putchar('\n');
  }
}
