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