#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long k = 0;
  if (n % 4 == 0) {
    k = n / 4;
  } else {
    k = (n / 4) + 1;
  }
  string ans = "";
  for (long long i = 0; i < k; i++) {
    ans += "8";
  }
  n -= k;
  for (long long i = 0; i < n; i++) {
    ans = "9" + ans;
  }
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
