#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
const int mod = 10007;
const double pi = acos(-1.0);
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int t = ceil(n / 4.0);
    for (int i = 0; i < n - t; i++) cout << 9;
    for (int i = 0; i < t; i++) cout << 8;
    cout << endl;
  }
}
