#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 1e5 + 6;
const long long int MOD = 1e9 + 7;
vector<int> prim(1000005, 1);
int fact[maxn];
long long int binomialCoeff(long long int n, long long int k) {
  long long int res = 1;
  if (k > n - k) k = n - k;
  for (long long int i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
int fenwick[1000001];
void update(int x, int val, int n) {
  while (x <= n) {
    fenwick[x] += val;
    x += (x & -x);
  }
}
int query(int i, int n) {
  int sum = 0;
  while (i > 0) {
    sum += fenwick[i];
    i -= (i & -i);
  }
  return sum;
}
void fenwic(int a[], int n, int c) {
  for (int i = 0; i < n; i++) {
    update(i + 1, c, n);
  }
}
bool isVowel(char ch) {
  if (ch == 'a' || ch == 'i' || ch == 'e' || ch == 'u' || ch == 'o') {
    return true;
  }
  return false;
}
long long int power(long long int x, long long int i, long long int mod) {
  long long int ans = 1;
  while (i > 0) {
    if (i & 1) ans = (ans * x) % mod;
    i >>= 1;
    x = (x * x) % mod;
  }
  return ans;
}
long long int modInverse(long long int x, long long int mod) {
  return power(x, mod - 2, mod);
}
int nCr(int n, int r) {
  if (n < r) {
    return 0;
  }
  return (((fact[n] * modInverse(fact[n - r], MOD)) % MOD) *
          modInverse(fact[r], MOD)) %
         MOD;
}
long long int power(int x, unsigned int y) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
void erath(int n) {
  prim[1] = 0;
  prim[0] = 0;
  prim[2] = 1;
  for (int i = 2; i * i <= n; i++) {
    if (prim[i]) {
      for (int j = i * i; j <= n; j += i) {
        prim[j] = 0;
      }
    }
  }
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a / gcd(a, b)) * b;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
long long int n, m, k;
void ans() {
  int n, siz, need = 9998;
  cin >> n;
  siz = n;
  need = (siz + 3) / 4;
  while (siz - need > 0) {
    cout << "9";
    siz--;
  }
  while (need--) {
    cout << "8";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int tes = 1;
  cin >> tes;
  while (tes--) {
    ans();
  }
  return 0;
}
