#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  long long int n, res, q, i;
  double p;
  cin >> t;
  while (t--) {
    cin >> n;
    p = n;
    q = ceil(p / 4);
    for (i = 1; i <= n - q; i++) cout << 9;
    for (i = 1; i <= q; i++) cout << 8;
    cout << endl;
  }
  return 0;
}
