#include <bits/stdc++.h>
using namespace std;
int nad() {
  int n;
  cin >> n;
  int x = ceil((double)n / 4.00000);
  for (int i = 1; i <= n - x; i++) {
    cout << "9";
  }
  for (int i = 1; i <= x; i++) {
    cout << "8";
  }
  cout << endl;
  return 0;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    nad();
  }
}
