#include <bits/stdc++.h>
using namespace std;
int T;
int n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> T;
  while (T--) {
    cin >> n;
    float FloatN = n;
    int Num8 = ceil(FloatN / 4);
    int Num9 = n - Num8;
    for (int i = 0; i < Num9; ++i) {
      cout << 9;
    }
    for (int i = 0; i < Num8; ++i) {
      cout << 8;
    }
    cout << endl;
  }
}
