#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, x, y, z, p, q, l, r, k,
    t = 1, n, m, cnt, curr, prev, ndx, i, j, rem, cnt1, cnt2, tmp, nxt, sum,
    ans, mx, mn;
string s = "", s1 = "", s2 = "";
void solve() {
  cin >> n;
  long long k = n / 4 + (n % 4 != 0);
  for (long long i = 0; i < n - k; i++) cout << 9;
  for (long long i = 0; i < k; i++) cout << 8;
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> t;
  while (t--) solve();
}
