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