#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, a, b, c, d, i, j, k, l, m, cnt;
  cin >> t;
  while (t--) {
    cin >> n;
    a = n / 4;
    if (a * 4 != n) a++;
    for (i = 1; i <= n - a; i++) cout << 9;
    for (j = 1; j <= a; j++) cout << 8;
    cout << endl;
  }
  return 0;
}
