#include <bits/stdc++.h>
using namespace std;
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;
  }
}
