#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2;
void solve() {
  long long n;
  cin >> n;
  long long x = n % 4, y = n / 4, c = 0;
  for (int i = 0; i < n - n / 4 - (x != 0); i++, c++) cout << '9';
  while (c < n) cout << '8', c++;
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) solve();
}
