#include <bits/stdc++.h>
using namespace std;
long long int ar[500009], br[500009], cr[500009], tr[500009];
long long int fx[] = {-1, 1, 0, 0};
long long int fy[] = {0, 0, 1, -1};
map<long long int, long long int> mp;
vector<long long int> v;
string s;
struct evan {
  long long int l, r, pos;
} st[500009];
bool com(evan i1, evan i2) { return (i1.r < i2.r); }
int main() {
  long long int a, b, c, d, e, i, j, k, x, y, z, f, g, h, n, m;
  cin >> a;
  while (a--) {
    cin >> b;
    c = b / 4;
    j = (b * 4) - b;
    b -= c;
    for (i = 1; i < b; i++) {
      cout << "9";
    }
    if (j % 4)
      cout << "8";
    else {
      cout << "9";
    }
    for (i = 1; i <= c; i++) {
      cout << "8";
    }
    cout << endl;
  }
}
