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