#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, x;
    cin >> n;
    if (n % 4 == 0) {
      x = n / 4;
    } else {
      x = (n / 4) + 1;
    }
    for (int i = 1; i <= n - x; i++) cout << "9";
    for (int i = 1; i <= x; i++) cout << "8";
    cout << endl;
  }
}
