#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long limit = 1LL * 1e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
signed main() {
  cout.tie(0);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    int v = n / 4 + bool(n % 4);
    for (int i = 0; i < n - v; ++i) cout << 9;
    for (int i = 0; i < v; ++i) cout << 8;
    cout << '\n';
  }
  return 0;
}
