#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
template <typename T>
void debug(vector<T> x) {
  for (auto e : x) {
    cout << e << " ";
  }
  cout << "\n";
}
void solve() {
  long long n;
  cin >> n;
  long long x = n / 4;
  long long y = n % 4;
  if (y % 4 == 0) {
    for (long long i = 0; i < n - x; i++) {
      cout << "9";
    }
    for (long long i = 0; i < x; i++) {
      cout << "8";
    }
    cout << "\n";
    return;
    ;
  } else {
    for (long long i = 0; i < n - (x + 1); i++) {
      cout << "9";
    }
    for (long long i = 0; i < x + 1; i++) {
      cout << "8";
    }
    cout << "\n";
    return;
    ;
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
