#include <bits/stdc++.h>
using namespace std;
const int dl = 1e9 + 7;
const int M = 5e4;
int a[M];
int div(int n) {
  int mx = 1;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) mx = i;
  }
  return mx;
}
void print(char c, int x) {
  for (int i = 0; i < x; i++) cout << c;
}
int main() {
  for (int i = 1; i < M; i++) {
    a[i] = a[i - 1] + i;
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    bool findd = 0;
    int first = upper_bound(a + 1, a + M, n) - a;
    first--;
    for (int i = first; i > 0; i--) {
      if (n % a[i] == 0) {
        int b = div(n / a[i]);
        int c = (n / a[i]) / b;
        if (b + c + i + 1 <= 1e5) {
          print('1', b);
          print('3', i + 1);
          print('7', c);
          cout << endl;
          findd = 1;
          break;
        }
      }
    }
    if (findd) continue;
    int a1 = div(n);
    n /= a1;
    first = upper_bound(a + 1, a + M, n) - a;
    first--;
    int x = n - a[first];
    int second = upper_bound(a + 1, a + M, x) - a;
    second--;
    for (int i = second; i > 0; i--) {
      if (x % a[i] == 0) {
        int y = x / a[i];
        print('1', a1);
        print('3', i + 1);
        print('7', y);
        print('3', first - i);
        print('7', 1);
        cout << endl;
        break;
      }
    }
  }
  return 0;
}
