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