#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int eights = ceil(n / 4.0);
    int nines = (n - eights);
    string s = "";
    for (int i = 0; i < nines; i++) s += "9";
    for (int i = 0; i < eights; i++) s += "8";
    cout << s << endl;
  }
  return 0;
}
