#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 100;
const long long INF = 9 * (long long)(1e18);
const long double PI = 3.14159265358979323846;
long long int modexp(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  if (y == 0)
    return 1;
  else if (x == 0)
    return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
vector<long long int> is_prime(N + 1, 1);
void sieve(long long int n) {
  for (long long int i = 1; i <= n; i++) is_prime[i] = i;
  for (long long int i = 2; i * i <= n; i++) {
    if (is_prime[i] == i) {
      for (long long int j = i * i; j <= n; j += i)
        is_prime[j] = min(i, is_prime[j]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int foo;
  cin >> foo;
  while (foo--) {
    long long int n;
    cin >> n;
    long long int x = (n + 3) / 4;
    string s = string(x, '8');
    n -= x;
    string s2 = string(n, '9');
    cout << s2 + s << "\n";
  }
}
