#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long long md = 1e9 + 7;
long long q, n, x, i;
void solve() {
  cin >> n;
  x = (n + 3) / 4;
  for (i = 1; i <= n - x; i++) cout << "9";
  for (i = 1; i <= x; i++) cout << "8";
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> q;
  while (q--) {
    solve();
  }
  return 0;
}
