#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    int x = (n + 3) / 4;
    for (int i = 1; i <= n - x; i++) printf("9");
    for (int i = 1; i <= x; i++) printf("8");
    printf("\n");
  }
  return 0;
}
