#include <bits/stdc++.h>
template <typename sp>
inline void qread(sp &x) {
  char ch = getchar(), lst = ' ';
  while (ch < '0' || ch > '9') lst = ch, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  if (lst == '-') x = -x;
}
int t, x;
int main() {
  qread(t);
  while (t--) {
    x = 0;
    qread(x);
    int e = ((x - 1) / 4) + 1;
    for (register int i = 1; i <= x - e; i++) printf("9");
    for (register int i = 1; i <= e; i++) printf("8");
    puts("");
  }
  return 0;
}
