#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int cnt = ceil((double)n / 4.0);
  for (int i = 1; i <= n - cnt; i++) cout << 9;
  for (int i = 1; i <= cnt; i++) cout << 8;
  cout << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
