#include <bits/stdc++.h>
using namespace std;
long long setBit(long long mask, int p) { return (mask | (1 << p)); }
long long resetBit(long long mask, int p) { return (mask & ~(1 << p)); }
long long flipBit(long long mask, int p) { return (mask ^ (1 << p)); }
bool check(long long mask, int p) { return (mask & (1 << p)); }
int msb(long long N) { return N ? 63 - __builtin_clzll(N) : -1; }
int lsb(long long N) { return __builtin_ffs(N) - 1; }
int countOn(long long mask) { return __builtin_popcountll(mask); }
int countOff(long long mask) { return msb(mask) - countOn(mask) + 1; }
long long bigmod(long long a, long long b, long long mod) {
  a %= mod;
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret;
}
long long modInverse(long long a) { return bigmod(a, 1, 1000000007 - 2); }
mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l, long long r) {
  return (mt_rnd_64() % (r - l + 1)) + l;
}
int main() {
  int i, n, t, rem;
  scanf("%d", &t);
  while (t--) {
    vector<int> v;
    scanf("%d", &n);
    rem = n / 4;
    if (n % 4) rem++;
    for (i = 0; i < n - rem; i++) printf("9");
    while (rem--) printf("8");
    printf("\n");
  }
}
