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