#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int ans = 0;
    string s = "";
    if (n % 4 == 0) {
      for (long long int i = 1; i <= n - n / 4; i++) s += '9';
      for (long long int i = 1; i <= n / 4; i++) s += '8';
    } else {
      for (long long int i = 1; i <= n - n / 4 - 1; i++) s += '9';
      for (long long int i = 1; i <= n / 4 + 1; i++) s += '8';
    }
    cout << s << endl;
  }
}
