#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int k = n / 4;
    if (n % 4 != 0) k++;
    int k1 = n - k;
    long long x = 0;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
      if (i < k1)
        v[i] = 9;
      else
        v[i] = 8;
    for (auto x : v) cout << x;
    cout << endl;
  }
}
