#include <bits/stdc++.h>
using namespace std;
void solve(long long n) {
  long long result = n / 4;
  long long remainder = n % 4;
  long long x = (n - result - 1);
  for (long long i = 0; i < x; i++) {
    cout << 9;
  }
  if (remainder == 0)
    cout << 9;
  else {
    cout << 8;
  }
  for (long long i = 0; i < result; i++) {
    cout << 8;
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, n, k;
  cin >> t;
  while (t--) {
    cin >> n;
    solve(n);
  }
  return 0;
}
