#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string x = "";
  int es = n / 4;
  if (n % 4) es++;
  n -= es;
  while (n--) {
    x.push_back('9');
  }
  while (es--) {
    x.push_back('8');
  }
  cout << x << "\n";
}
int main() {
  int t;
  t = 1;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
}
