#include <bits/stdc++.h>
#pragma GCC optimize( \
    "Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
using namespace std;
const int N = 1e2 + 5, M = 2 * N + 5;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    int e = (n + 3) / 4;
    n -= e;
    while (n--) printf("9");
    while (e--) printf("8");
    puts("");
  }
}
