#include <bits/stdc++.h>
using namespace std;
void solve();
void YN(bool b) {
  if (b) {
    cout << "YES"
         << "\n";
    ;
  } else {
    cout << "NO"
         << "\n";
    ;
  }
};
void yn(bool b) {
  if (b) {
    cout << "Yes"
         << "\n";
    ;
  } else {
    cout << "No"
         << "\n";
    ;
  }
};
void queries() {
  int n;
  cin >> n;
  while (n--) solve();
}
const int maxn = 200200;
void solve() {
  int n;
  cin >> n;
  int x = n / 4 + (n % 4 != 0);
  for (int i = 0; i < n - x; i++) {
    cout << 9;
  }
  for (int i = 0; i < x; i++) {
    cout << 8;
  }
  cout << "\n";
  ;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  queries();
  ;
  return 0;
}
