#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int i, t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    if (n == 1) {
      cout << "8\n";
      continue;
    }
    long long int x = n / 4;
    if (n % 4 > 0) x++;
    n -= x;
    while (n--) cout << "9";
    while (x--) cout << "8";
    cout << '\n';
  }
  return 0;
}
