#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int d = (n + 3) / 4;
    cout << string(n - d, '9') << string(d, '8') << '\n';
  }
  return 0;
}
