#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, l, i, j, k, f, n, b, m, z, ml, g;
  char c;
  cin >> t;
  string s, y;
  while (t--) {
    cin >> n;
    k = (n + 3) / 4;
    m = n - k;
    for (i = 0; i < m; i++) cout << 9;
    for (i = 0; i < k; i++) cout << 8;
    cout << endl;
  }
  return 0;
}
