#include <bits/stdc++.h>
int main() {
  int n = 0, k = 0;
  scanf("%d", &n);
  int rez[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &k);
    rez[i] = k;
  }
  for (int i = 0; i < n; ++i) {
    int e = (rez[i] - 1) / 4 + 1;
    for (int j = 0; j < rez[i] - e; ++j) {
      printf("9");
    }
    for (int j = 0; j < e; ++j) {
      printf("8");
    }
    printf("\n");
  }
  return 0;
}
