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