Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it.

In the beginning, uncle Bogdan wrote on a board a positive integer $x$ consisting of $n$ digits. After that, he wiped out $x$ and wrote integer $k$ instead, which was the concatenation of binary representations of digits $x$ consists of (without leading zeroes). For example, let $x = 729$, then $k = 111101001$ (since $7 = 111$, $2 = 10$, $9 = 1001$).

After some time, uncle Bogdan understood that he doesn't know what to do with $k$ and asked Denis to help. Denis decided to wipe last $n$ digits of $k$ and named the new number as $r$.

As a result, Denis proposed to find such integer $x$ of length $n$ that $r$ (as number) is maximum possible. If there are multiple valid $x$ then Denis is interested in the minimum one.

All crew members, including captain Flint himself, easily solved the task. All, except cabin boy Kostya, who was too drunk to think straight. But what about you?

Note: in this task, we compare integers ($x$ or $k$) as numbers (despite what representations they are written in), so $729 < 1999$ or $111 < 1000$.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.

Next $t$ lines contain test cases — one per test case. The one and only line of each test case contains the single integer $n$ ($1 \le n \le 10^5$) — the length of the integer $x$ you need to find.

It's guaranteed that the sum of $n$ from all test cases doesn't exceed $2 \cdot 10^5$.


-----Output-----

For each test case, print the minimum integer $x$ of length $n$ such that obtained by Denis number $r$ is maximum possible.


-----Example-----
Input
2
1
3

Output
8
998



-----Note-----

In the second test case (with $n = 3$), if uncle Bogdan had $x = 998$ then $k = 100110011000$. Denis (by wiping last $n = 3$ digits) will obtain $r = 100110011$.

It can be proved that the $100110011$ is the maximum possible $r$ Denis can obtain and $998$ is the minimum $x$ to obtain it.

Difficulty: EASY
Tags: Mathematics

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
import math
t = int(input())
for w in range(t):
	n = int(input())
	k = math.ceil(n / 4)
	print('9' * (n - k) + '8' * k)


t = int(input())
count = 0
while t != count:
	count += 1
	n = int(input())
	floor = n // 4
	if n % 4 != 0:
		divisivel = floor + 1
	else:
		divisivel = floor
	print('9' * (n - divisivel) + '8' * divisivel)


t = int(input())
while t != 0:
	n = int(input())
	l = []
	temp = n
	while n != 0:
		a = 9
		l += [1, 0, 0, 1]
		n -= 1
	length = len(l)
	ans = ''
	for i in range(length - temp, length, 1):
		l[i] = 0
	for i in range(0, len(l), 4):
		ans += str(l[0] * 8 + l[i + 1] * 4 + l[i + 2] * 2 + l[i + 3])
	print(ans)
	t -= 1


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	n = int(input())
	k = n // 4
	if n % 4:
		k += 1
	print('9' * (n - k) + '8' * k)


for _ in range(int(input())):
	n = int(input())
	s = ''
	if n % 4 == 0:
		k = n // 4
	else:
		k = n // 4 + 1
	for i in range(n - k):
		s = s + '9'
	for i in range(k):
		s = s + '8'
	print(int(s))


import math
for _ in range(int(input())):
	n = int(input())
	l = ''
	eights = 0
	if n % 4 == 0:
		eights = n // 4
	else:
		eights = math.ceil(n / 4)
	for i in range(n - eights):
		l += '9'
	for i in range(eights):
		l += '8'
	print(''.join(l))


t = int(input())
for _ in range(t):
	n = int(input())
	if n % 4 == 0:
		f = n // 4
	else:
		f = n // 4 + 1
	print('9' * (n - f) + '8' * f)


from math import ceil
t = int(input())
for _ in range(t):
	n = int(input())
	s = []
	if n == 1:
		print(8)
	else:
		s = ['9'] * (n - int(ceil(n / 4)))
		s += ['8'] * int(ceil(n / 4))
	print(''.join(s))


for t in range(int(input())):
	n = int(input())
	a = n // 4
	if n % 4 == 0:
		s = '9' * (n - a)
		s1 = '8' * a
	else:
		s = '9' * (n - a - 1)
		s1 = '8' * (a + 1)
	res = int(s + s1)
	print(res)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	suff = (n + 3) // 4
	print((n - suff) * '9' + suff * '8')


t = int(input())
for _ in range(t):
	n = int(input())
	x = int((n + 3) / 4)
	for i in range(n - x):
		print(9, end='')
	for i in range(x):
		print(8, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	p = (n + 3) // 4
	print('9' * (n - p) + '8' * p)


import math
a = int(input())
for i in range(0, a):
	b = int(input())
	t = math.ceil(b / 4)
	ans = [9] * (b - t)
	for i in range(0, t):
		ans.append(8)
	print(''.join(map(str, ans)))


import math
for _ in range(int(input())):
	n = int(input())
	t = ['0', '1', '10', '11', '100', '101', '110', '111', '1000', '1001']
	s = math.ceil(n / 4) * '8'
	s = (n - len(s)) * '9' + s
	print(s)


for i in range(int(input())):
	n = int(input())
	rem = n % 4
	whole = n // 4
	if rem:
		whole += 1
	answer = '9' * (n - whole) + '8' * whole
	print(answer)


import math
for _ in range(int(input())):
	n = int(input())
	p = math.ceil(n / 4)
	f_ans = '9' * (n - p) + '8' * p
	print(f_ans)


def convert(n):
	ans = ''
	while n != 0:
		temp = n % 10
		ans += bin(temp)[2:]
		n = n // 10
	return ans
from math import ceil
t = int(input())
for _ in range(t):
	n = int(input())
	temp = ceil(n / 4)
	print('9' * (n - temp) + '8' * temp)


from math import ceil
t = int(input())
for _ in range(t):
	n = int(input())
	num = ''
	if n % 4 != 0:
		digit_8 = n // 4 + 1
	else:
		digit_8 = n // 4
	for i in range(n - digit_8):
		num += '9'
	num += '8' * digit_8
	print(int(num))


import math
t = int(input())
for i in range(t):
	n = int(input())
	k = math.ceil(n / 4)
	a = '8' * k
	p = ''.join(list(a))
	a1 = '9' * (n - k)
	p1 = ''.join(list(a1))
	print(p1 + p)


def get8count(n):
	if n % 4 == 0:
		return n // 4
	else:
		return n // 4 + 1
t = int(input())
for some_num in range(0, t):
	n = int(input())
	k = get8count(n)
	number = '9' * (n - k) + '8' * k
	print(number)


for i in range(0, int(input())):
	n = int(input())
	c = n // 4
	if n % 4 == 0:
		for j in range(0, n - c):
			print('9', end='')
		for j in range(0, c):
			print('8', end='')
		print()
	else:
		c += 1
		for j in range(0, n - c):
			print('9', end='')
		for j in range(0, c):
			print('8', end='')
		print()


def solve(n):
	count_of_eights = (n - 1) // 4 + 1
	answ = '9' * (n - count_of_eights) + '8' * count_of_eights
	print(answ)
t = int(input())
for i in range(t):
	n = int(input())
	solve(n)


t = int(input())
for _ in range(t):
	n = int(input())
	eights = (n + 3) // 4
	eights = int(eights)
	print('9' * (n - eights) + '8' * eights)


for _ in range(int(input())):
	n = int(input())
	x = n * 3
	ans = ''
	ans += '9' * (x // 4)
	ans += '8' * (n - x // 4)
	print(ans)


import sys
import heapq

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		ndiv = (n - 1) // 4
		nrem = (n - 1) % 4
		ans = '9' * (n - (ndiv + 1)) + '8' * (ndiv + 1)
		print(ans)
	return
main()


from math import ceil

def main():
	T = int(input())
	for _ in range(T):
		n = int(input())
		t = int(ceil(n / 4))
		n1 = ['9' for c in range(n - t)]
		t1 = ['8' for c in range(t)]
		ns = ''.join(n1)
		ts = ''.join(t1)
		r = ns + ts
		print(r)
main()


import math
import sys

def main():
	for i in range(int(input())):
		x = int(input())
		n = math.floor((x + 3) / 4)
		for j in range(x - n):
			sys.stdout.write(str(9))
		for k in range(n):
			sys.stdout.write(str(8))
		sys.stdout.write('\n')
main()


for i in range(int(input())):
	n = int(input())
	a = ''
	eights = n // 4 + 1
	if n % 4 == 0:
		eights -= 1
	a += eights * '8'
	n -= len(a)
	b = n * '9' + a
	print(b)


for _ in [0] * int(input()):
	n = int(input())
	print('9' * (n - 1 - (n - 1) // 4) + '8' * (1 + (n - 1) // 4))


for _ in range(int(input())):
	n = int(input())
	ls1 = '9' * n
	b = []
	for i in ls1:
		b.append(bin(int(i))[2:])
	s = ''.join(b)[:-n] + '0' * n
	p = []
	for i in range(0, len(s), 4):
		p.append(str(int(s[i:i + 4], 2)))
	for i in range(len(p)):
		if p[i] == '0':
			p[i] = '8'
	print(''.join(p))


for t in range(int(input())):
	x = int(input())
	l = int('1' + '0' * (x - 1))
	h = int('9' * x)
	a = x // 4
	b = x % 4
	if x % 4:
		print('9' * (x - a - 1) + '8' * (a + 1))
	else:
		print('9' * (x - a) + '8' * a)


import math
for _ in range(int(input())):
	n = int(input())
	n1 = math.ceil(n / 4)
	n2 = n - n1
	print(int(n2 * '9' + n1 * '8'))


from math import ceil
Answer = []
for _ in range(int(input())):
	N = int(input())
	print('9' * (N - ceil(N / 4)) + '8' * ceil(N / 4))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = int(math.ceil(n / 4))
	print((n - a) * '9' + a * '8')


t = int(input())
for _ in range(t):
	n = int(input())
	dig = n // 4
	if n % 4 != 0:
		dig += 1
	print('9' * (n - dig) + '8' * dig)


for t in range(int(input())):
	n = int(input())
	x = n * 4
	r = x - n
	nines = r // 4
	eights = n - nines
	num = '9' * nines + '8' * eights
	print(int(num))


def solution():
	n = int(input())
	x = n // 4
	if n % 4 != 0:
		x += 1
	print('9' * (n - x) + '8' * x)
t = int(input())
for _ in range(t):
	solution()


from math import ceil
for _ in range(int(input())):
	n = int(input())
	m = n / 4
	m = ceil(m)
	print('9' * (n - m) + '8' * m)


num = [0]
count = 1
for i in range(1, 10 ** 5 + 10):
	num.append(count)
	if i % 4 == 0:
		count += 1
for _ in range(int(input())):
	n = int(input())
	number_of_8 = num[n]
	number_of_9 = n - number_of_8
	print('9' * number_of_9 + '8' * number_of_8)


t = int(input())
for i in range(t):
	n = int(input())
	eights = n // 4 + (1 if n % 4 else 0)
	nines = n - eights
	print(nines * '9' + eights * '8')


t = int(input())
for rep in range(t):
	n = int(input())
	c8 = (n + 3) // 4
	c9 = n - c8
	ans = '9' * c9 + '8' * c8
	print(ans)


import io
import os
import sys
from collections import deque, defaultdict
from itertools import accumulate
inf = 1 << 65

def _input():
	x = sys.stdin.readline()
	x = x.replace('\r', '')
	x = x.replace('\n', '')
	return x
if 'STDINPUT' not in os.environ:
	input = _input
else:
	print('Standard input')
primes = []
isp = {}
for i in range(2, 2 * 10 ** 5 + 1):
	if i not in isp:
		primes.append(i)
		isp[i] = 1
		for j in range(i + i, 2 * 10 ** 5 + 1, i):
			isp[j] = 1

def solve():
	n = int(input())
	eights = max(1, (n - 1) // 4 + 1)
	print(*[9] * (n - eights) + [8] * eights, sep='')
test_cases = True
if test_cases:
	_q = int(input())
	for _ in range(_q):
		solve()
else:
	solve()


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		q = n // 4
		r = n % 4
		if r != 0:
			q += 1
		s = (n - q) * '9' + q * '8'
		print(s)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		print(8)
	else:
		lm = (n + 3) // 4
		res = '9' * (n - lm) + '8' * lm
		print(res)


t = int(input())
for i in range(t):
	n = int(input())
	k = (n + 3) // 4
	print('9' * (n - k) + '8' * k)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
for _ in range(int(input())):
	n = int(input())
	t = n * 4 - n
	x = '9' * (t // 4)
	if t % 4 > 0:
		x += '8'
	x += '8' * (n - len(x))
	print(x)


from math import ceil
for i in range(int(input())):
	n = int(input())
	a = ceil(n / 4)
	number = ''
	for j in range(n):
		if j + 1 > a:
			number += '9'
		else:
			number += '8'
	print(number[::-1])


import math
for i in range(int(input())):
	number = int(input())
	number_mod = 10 ** number
	temp = math.ceil(number / 4)
	nines = number - temp
	eights = temp
	list_ = []
	for i in range(nines):
		list_.append(9)
	for i in range(eights):
		list_.append(8)
	final = ''.join([str(x) for x in list_])
	print(int(final))


import sys
import math

def solve(n):
	eights = math.ceil(n / 4)
	return '9' * (n - eights) + '8' * eights
caseCount = int(next(sys.stdin))
for i in range(caseCount):
	n = int(next(sys.stdin))
	x = solve(n)
	print(x)


import sys, collections
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
t = inp()
for _ in range(t):
	n = inp()
	a = -(-n // 4)
	print('9' * (n - a) + '8' * a)


from collections import deque
from math import *
import heapq
from random import *
import sys
t = int(input())
for i in range(t):
	n = int(input())
	if n % 4 == 0:
		val = n // 4
		diff = n - val
		print(int('9' * diff + '8' * val))
	else:
		val = n // 4
		diff = n - val
		print(int('9' * (diff - 1) + '8' + '8' * val))


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
for __ in range(int(input())):
	n = int(input())
	ans = ''
	t = 4 * n - n
	rslt = ''
	a = ''
	for i in range(n * 4):
		if ((i + 1) % 4 == 1 or (i + 1) % 4 == 0) and i < t:
			ans += '1'
			a += '1'
		else:
			ans += '0'
			a += '0'
		if len(ans) == 4:
			if int(ans, 2) == 0:
				rslt += '8'
			else:
				rslt += str(int(ans, 2))
			ans = ''
	print(rslt)


from collections import defaultdict
import bisect
import math

def solve(n):
	k = math.ceil(n / 4)
	n -= k
	ans = '9' * n + '8' * k
	return int(ans)
for _ in range(int(input())):
	n = int(input())
	print(solve(n))


import sys
input = sys.stdin.readline

def solution():
	N = int(input())
	t = N // 4
	if N % 4 != 0:
		t += 1
	print('9' * (N - t) + '8' * t)
T = int(input())
for _ in range(T):
	solution()


from sys import stdin, stdout
for query in range(int(stdin.readline())):
	n = int(stdin.readline())
	if n % 4 == 0:
		x = n // 4
	else:
		x = n // 4 + 1
	for y in range(n - x):
		stdout.write('9')
	for y in range(x):
		stdout.write('8')
	stdout.write('\n')


t = int(input())
for i in range(t):
	n = int(input())
	s = '9' * n
	if n % 4 == 0:
		d = n // 4
	else:
		d = n // 4 + 1
	m8 = '8' * d
	s = s[:n - d] + m8
	print(s)


P = ''
for _ in range(int(input())):
	n = int(input())
	ans = (n - 1) // 4
	P += '9' * (n - ans - 1) + '8' * (ans + 1)
	P += '\n'
print(P)


test = int(input())
for i in range(test):
	l = int(input())
	k = l // 4
	if l % 4 > 0:
		k += 1
	t = abs(k - l)
	print('9' * t + '8' * k)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math
for _ in range(ri()):
	n = ri()
	w = math.ceil(n / 4)
	s = '9' * (n - w) + '8' * w
	print(s)


def voyage(n):
	rem = n
	count = 0
	while rem > 0:
		rem = rem - 4
		count += 1
	t = '8' * count
	p = n - count
	aux = '9' * p
	s = aux + t
	return int(s)
t = int(input())
for i in range(t):
	n = int(input())
	print(voyage(n))


t = int(input())
while t:
	n = int(input())
	n1 = n * 4
	nine = (n1 - n) // 4
	n -= nine
	while nine:
		print(9, end='')
		nine -= 1
	while n:
		print(8, end='')
		n -= 1
	print()
	t -= 1


for test in range(int(input())):
	n = int(input())
	a = ['000', '001', '010', '011', '100', '101', '110', '111', '1000', '1001']
	tt = n // 4
	if n % 4 == 0:
		print('9' * (n - tt) + '8' * tt)
	else:
		print('9' * (n - tt - 1) + '8' * (tt + 1))


import sys
input = sys.stdin.readline
f = lambda : map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		print('9' * (n - n // 4) + '8' * (n // 4))
	else:
		print('9' * (n - n // 4 - 1) + '8' * (n // 4 + 1))


t = int(input())
for _ in range(t):
	n = int(input())
	n8 = (n + 3) // 4
	n9 = n - n8
	print(''.join(['9'] * n9 + ['8'] * n8))


test = int(input())
for j in range(test):
	n = int(input())
	while False:
		break
	if n == 1:
		print(8)
		continue
	ans = int(3 * n / 4)
	xx = ans * '9' + (n - ans) * '8'
	while False:
		break
	s = int(xx)
	print(xx)


for _ in range(int(input())):
	n = int(input())
	n = n - 1
	cal = n // 4
	rem = n - cal
	print('9' * rem, end='')
	print('8' * cal, end='')
	print('8')


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
		continue
	tmp = (n - 1) // 4
	tmp += 1
	out = '9' * (n - tmp) + '8' * tmp
	print(out)


T = int(input())
for _ in range(T):
	n = int(input())
	r = [9] * n
	x = 1
	while n > 0:
		r[-x] -= 1
		x += 1
		n -= 4
	print(''.join(map(str, r)))


t = int(input())
for i in range(t):
	n = int(input())
	e = n // 4
	if n % 4 != 0:
		e += 1
	eight = '8' * e
	nine = '9' * (n - e)
	print(nine + eight)


t = int(input())
for _ in range(0, t):
	n = int(input())
	mod_n = n % 4
	div_n = n // 4
	for i in range(0, n - div_n - 1):
		print('9', end='')
	if mod_n == 0:
		print('9', end='')
	else:
		print('8', end='')
	for i in range(0, div_n):
		print('8', end='')
	print()


import math

def calculate(n):
	nine = '9'
	zero = '0'
	eight = '8'
	result = ''
	for i in range(math.floor(3 * n / 4)):
		result += nine
	if n % 4 == 0:
		for i in range(int(n / 4)):
			result += eight
	else:
		result += eight
		for i in range(int((n - 4 + 3 * n % 4) / 4)):
			result += eight
	return int(result)
tests = int(input())
while tests:
	n = int(input())
	print(calculate(n))
	tests -= 1


for _ in range(int(input())):
	n = int(input())
	count = 0
	ans = ['' for i in range(n)]
	for i in range(n):
		if count >= 3 * n:
			ans[i] = '8'
		elif 3 * n - count >= 4:
			ans[i] = '9'
			count += 4
		else:
			ans[i] = '8'
			count += 4
	print(''.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	cnt8 = n // 4
	if n % 4 != 0:
		cnt8 += 1
	ans = '9' * (n - cnt8) + '8' * cnt8
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	eights = 0
	des = n
	while des > 0:
		eights += 1
		des -= 4
	print('9' * (n - eights) + '8' * eights)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		num = (n - 1) // 4 + 1
		yield ((n - num) * '9' + num * '8')
t = int(input())
ans = gift()
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	r = 3 * n
	r = r // 4
	ans = '9' * r
	ans += '8' * (n - r)
	print(ans)


import math
T = int(input())
for t in range(T):
	n = int(input())
	rem = math.ceil(n / 4)
	ans = ''
	for i in range(n - rem):
		ans += '9'
	for i in range(rem):
		ans += '8'
	print(ans)


for t in range(1, int(input()) + 1):
	n = int(input())
	f = n // 4
	r = n % 4
	ans = '9' * (n - f - 1)
	if r == 0:
		ans += '9'
	else:
		ans += '8'
	ans += '8' * f
	print(ans)


a = int(input())
A = []
nine = '9'
eight = '8'
for i in range(a):
	x = int(input())
	ans = ''
	if x % 4 == 0:
		ans += eight * (x // 4)
		ans = nine * (x - len(ans)) + ans
	else:
		ans += eight * (x // 4 + 1)
		ans = nine * (x - len(ans)) + ans
	A.append(ans)
for i in range(a):
	print(A[i])


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = []
	if n == 1:
		print(8)
	elif n == 2:
		print(98)
	else:
		eight = math.ceil(n / 4)
		s = '9' * (n - eight) + '8' * eight
		print(int(s))


def solve():
	n = int(input())
	m = n // 4
	if n % 4 == 0:
		return '9' * (n - m) + '8' * m
	else:
		return '9' * (n - m - 1) + '8' * (m + 1)

def main():
	t = int(input())
	ANS = [solve() for _ in range(t)]
	print('\n'.join(ANS))
main()


for t in range(int(input())):
	n = int(input())
	ans = '9' * n
	replace = n // 4
	if n % 4 > 0:
		replace += 1
	new_ans = ans[0:-replace]
	new_ans += '8' * replace
	print(new_ans)


for i in range(int(input())):
	n = int(input())
	x = (n + 3) // 4
	print('9' * (n - x), '8' * x, sep='')


import math
t = int(input())
for g in range(t):
	n = int(input())
	a = math.ceil(n / 4)
	ans = '9' * (n - a) + '8' * a
	print(ans)


for test_i in range(int(input())):
	n = int(input())
	print('9' * (n - 1 - (n - 1) // 4) + '8' * ((n - 1) // 4 + 1))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	e = (n - 1) // 4 + 1
	s = '9' * (n - e) + '8' * e
	print(s)


for case in range(int(input())):
	n = int(input())
	x = n % 4
	a = n
	if x != 0:
		a += 4 - x
	l = a // 4
	print('9' * (n - l) + '8' * l)


def solve():
	n = int(input())
	x = int((n + 3) / 4)
	nine = '9' * (n - x)
	eight = '8' * x
	print(nine + eight)
for t in range(int(input())):
	solve()


T = int(input())
for z in range(T):
	n = int(input())
	n8 = n // 4
	if n % 4 != 0:
		n8 += 1
	s = ''
	for i in range(n - n8):
		s = s + '9'
	for i in range(n8):
		s = s + '8'
	print(int(s))


T = int(input())
for _ in range(T):
	n = int(input())
	k = (n + 3) // 4
	print('9' * (n - k) + '8' * k)


from math import ceil
for _ in range(int(input())):
	n = int(input())
	c8 = ceil(n / 4)
	c9 = n - c8
	print('9' * c9 + '8' * c8)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	if n % 4 != 0:
		print('9' * (n - n // 4 - 1) + '8' * (n // 4 + 1))
	else:
		print('9' * (n - n // 4) + '8' * (n // 4))


for _ in range(int(input())):
	n = int(input())
	p = int(n / 4)
	if n % 4 != 0:
		p += 1
	n = n - p
	for i in range(n):
		print('9', end='')
	for i in range(p):
		print('8', end='')
	print()


from sys import stdout, stdin
from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	z = n // 4
	r = n % 4
	s = ''
	for i in range(n - z - 1):
		s += '9'
	if r > 0:
		s += '8'
	else:
		s += '9'
	for i in range(z):
		s += '8'
	stdout.write(s + '\n')


import math
CASES = int(input())
for i in range(CASES):
	n = int(input())
	k = math.ceil(n / 4)
	print((n - k) * '9' + k * '8')


import sys
from math import ceil
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	suffix = ceil(n / 4)
	pre = n - suffix
	for i in range(pre):
		print(9, end='')
	for i in range(suffix):
		print(8, end='')
	print()


for i in range(int(input())):
	n = int(input())
	print('9' * (n - (n - 1) // 4 - 1) + '8' * ((n - 1) // 4 + 1))


import sys
import math
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	rem = math.ceil(n / 4)
	result_str = '9' * (n - rem)
	for i in range(rem):
		result_str += '8'
	print(result_str)


from math import *
t = int(input())
for _ in range(t):
	n = int(input())
	s = ceil(n / 4)
	print((n - s) * '9' + s * '8')


from math import ceil

def func(n):
	eight = ceil(n / 4)
	num = '9' * (n - eight) + '8' * eight
	return int(num)
t = int(input())
for _ in range(t):
	a = int(input())
	print(func(a))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	p = math.ceil(n / 4)
	ans = '9' * (n - p)
	ans += '8' * p
	print(ans)


def solve(n):
	return '9' * (n - 1 - n // 4) + ('9' if n % 4 == 0 else '8') + '8' * (n // 4)
for t in range(int(input())):
	print(solve(int(input())))


import sys
input = sys.stdin.readline
for f in range(int(input())):
	n = int(input())
	delet = (n + 3) // 4
	rem = n - delet
	for i in range(rem):
		print(9, end='')
	for i in range(delet):
		print(8, end='')
	print()


import math
for _ in range(int(input())):
	n = int(input())
	k = math.ceil(n / 4)
	print((n - k) * '9' + k * '8')


for i in range(int(input())):
	n = int(input())
	k = n // 4
	if n % 4 != 0:
		k = k + 1
	print('9' * (n - k), end='')
	print('8' * k)


t = int(input())
while t > 0:
	n = int(input())
	if n % 4 == 0:
		k = n // 4
		print('9' * (n - k) + '8' * k)
	else:
		k = n // 4 + 1
		print('9' * (n - k) + '8' * k)
	t = t - 1


from math import ceil
t = int(input())
while t:
	n = int(input())
	print('9' * int(n - ceil(n / 4)), int(ceil(n / 4)) * '8', sep='')
	t -= 1


import math
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	a = math.ceil(n / 4)
	n = n - a
	s = '9' * n
	b = '8' * a
	s = s + b
	num = int(s)
	print(num)


for _ in range(int(input())):
	n = int(input())
	cnt = 0
	for i in range(1, n):
		if i % 4 == 0:
			cnt += 1
	g = n - (cnt + 1)
	print(int(g * '9' + (n - g) * '8'))


def test_cases():
	n = int(input())
	c = n // 4 + 1
	r = n % 4
	if n % 4 == 0:
		c -= 1
		s = (n - c) * '9' + c * '8'
	else:
		s = (n - c) * '9' + c * '8'
	print(s)

def start():
	for t in range(int(input())):
		test_cases()
start()


import math
for case in range(int(input())):
	d = int(input())
	l = d * 4
	t = math.ceil(d / 4)
	d -= t
	print('9' * d + '8' * t)


cases = int(input())
import math
for i in range(cases):
	length = int(input())
	ans = length * 4
	diff = ans - length
	string = ''
	while diff >= 4:
		string += '9'
		diff -= 4
	l = len(string)
	d2 = length - l
	string += d2 * '8'
	print(string)


q = int(input())
for o in range(q):
	n = int(input())
	a = []
	for i in range(n):
		a.append(9)
	x = n // 4
	y = n % 4
	for i in range(x):
		a[n - i - 1] = 8
	if y != 0:
		a[n - x - 1] -= 1
	for i in range(n):
		print(a[i], end='')
	print()


import math
tot = int(input().strip())
while tot > 0:
	n = int(input().strip())
	print('9' * (n - math.ceil(n / 4)) + '8' * math.ceil(n / 4))
	tot -= 1


def solution(n):
	x = (n + 3) // 4
	ans = '9' * (n - x) + '8' * x
	return ans
for _ in range(int(input())):
	n = int(input())
	print(solution(n))


for _ in range(int(input())):
	n = int(input())
	b = bin(10 ** n - 1)[2:]
	(x, y) = divmod(n, 4)
	r = '8' * (x + int(y != 0))
	print((r + '9' * n)[:n][::-1])


import math
for i in range(int(input())):
	n = int(input())
	s = math.ceil(n / 4)
	a = '9' * (n - s)
	a = a + '8' * s
	print(a)


for t in range(int(input())):
	n = int(input())
	a = []
	b = (n + 3) // 4
	a.append('9' * (n - b))
	a.append('8' * b)
	a1 = ''.join(a)
	print(int(a1))


t = int(input())
for _ in range(t):
	n = int(input())
	cnt = (n - 1) // 4 + 1
	print('9' * (n - cnt) + '8' * cnt)


from math import ceil
for _ in range(int(input())):
	n = int(input())
	egt = ceil(n / 4)
	ans = '9' * (n - egt) + '8' * egt
	print(ans)


import math
import sys
input = sys.stdin.readline
t = int(input())
for ii in range(t):
	n = int(input())
	ans = '9' * (n - math.ceil(n / 4))
	ans += '8' * math.ceil(n / 4)
	print(ans)


import math
test = int(input())
for q in range(test):
	n = int(input())
	y = ''
	for i in range(n - math.ceil(n / 4)):
		y += '9'
	for i in range(math.ceil(n / 4)):
		y += '8'
	print(y)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	numEight = math.ceil(n / 4)
	numNine = n - numEight
	for i in range(numNine):
		print(9, end='')
	for i in range(numEight):
		print(8, end='')
	print()


t = int(input())
for z in range(t):
	n = int(input())
	k = n // 4
	if n % 4 == 0:
		k -= 1
	print('9' * (n - k - 1) + '8' * (k + 1))


from math import floor
results = []
tests = int(input())
for _x in range(tests):
	n = int(input())
	t = floor(n / 4) + (0 if n % 4 == 0 else 1)
	temp = '9' * (n - t)
	temp += '8' * t
	results.append(temp)
print(*results, sep='\n')


from collections import defaultdict as dc
import sys
import math
mod = 10 ** 9 + 7

def sinp():
	p = str(sys.stdin.readline())
	return p

def seive(n):
	p = [0] * (n + 1)
	for i in range(2, n):
		for j in range(2 * i, n + 1, i):
			p[i] = 1
	return p

def inp():
	p = int(sys.stdin.readline())
	return p

def line():
	p = list(map(int, sys.stdin.readline().split()))
	return p

def read_mat():
	n = inp()
	a = []
	for i in range(n):
		a.append(line())
	return a

def ind(a):
	return ord(a) - ord('A')

def digit(n):
	p = [int(i) for i in str(n)]
	return p

def check(p, n):
	l = str(p)
	s = ''
	for i in range(n):
		s = s + bin(int(l[i]))[2:]
	s = s[:-n]
	if s == '':
		return 0
	return int(s, 2)
t = inp()
for _ in range(t):
	n = inp()
	z = math.ceil(n / 4)
	l = '9' * (n - z) + '8' * z
	print(l)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	n = ii1()
	t = ceil(n / 4)
	res = '9' * (n - t) + '8' * t
	stdout.write(res + '\n')


for __ in range(int(input())):
	n = int(input())
	l = []
	if n % 4 == 0:
		c = n // 4
		for i in range(n - c):
			l.append('9')
		for i in range(c):
			l.append('8')
		s = ''
		s = s.join(l)
		x = int(s)
		print(x)
	else:
		c = n // 4
		for i in range(n - c - 1):
			l.append('9')
		l.append('8')
		for i in range(c):
			l.append('8')
		s = ''
		s = s.join(l)
		x = int(s)
		print(x)


import math
ls = lambda : list(map(int, input().split()))
ip = lambda : int(input())
sip = lambda : input()
r = lambda a: range(a)
lcm = lambda a, b: abs(a * b) // math.gcd(a, b)
t = ip()
for _ in r(t):
	n = ip()
	r = n % 4
	d = n // 4
	if n < 4:
		res = '9' * (n - 1) + '8'
	elif r > 0:
		res = '9' * (n - d - 1) + '8' * (d + 1)
	else:
		res = '9' * (n - r - d) + '8' * d
	print(int(res))


import math
for i in range(int(input())):
	n = int(input())
	t = math.ceil(n / 4)
	print((n - t) * '9' + t * '8')


import math
for _ in range(int(input().strip())):
	n = int(input().strip())
	j = n // 4
	if n % 4 != 0:
		j = math.ceil(n / 4)
	else:
		j = n // 4
	res = ''
	for i in range(n - j):
		res += '9'
	for i in range(j):
		res += '8'
	print(res)


import sys
q = int(input())
for i in range(q):
	n = int(sys.stdin.readline())
	tak = (n * 4 - n) // 4
	print('9' * tak + '8' * (n - tak))


for _ in range(int(input())):
	n = int(input())
	x = (n - 1) // 4 + 1
	l = ['9'] * (n - x) + ['8'] * x
	print(''.join(l))


import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def inc(d, c):
	d[c] = d[c] + 1 if c in d else 1

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)

def bo(i):
	return ord(i) - ord('a')

def ck(x, y):
	return int(bin(x)[2:] + bin(y)[2:], 2)

def brute(n):
	maxi = [-1, -1]
	for i in range(10 ** (n - 1), int('9' * n) + 1):
		s = i
		v = []
		p = ''
		while s > 0:
			v.append(bin(s % 10)[2:])
			s //= 10
		for ii in range(len(v) - 1, -1, -1):
			p += v[ii]
		p = p[:len(p) - n]
		if len(p) == 0:
			continue
		if maxi[0] < int(p, 2):
			maxi = [int(p, 2), i]
	print(maxi[1])
t = fi()
while t > 0:
	t -= 1
	n = fi()
	p = n // 4
	q = n % 4
	ans = '9' * (n - p)
	if q == 0:
		print('9' * (n - p) + '8' * p)
	else:
		print('9' * (n - p - 1) + '8' * (p + 1))


from collections import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	n = ri()
	if n == 1:
		print(8)
	else:
		q = (n - 1) // 4
		ans = '9' * (n - 1 - q) + '8' * (q + 1)
		print(ans)


from math import ceil

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		l = ceil(n / 4)
		print('9' * (n - l) + '8' * l)
main()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	num_8 = math.ceil(n / 4)
	num_9 = n - num_8
	print('9' * num_9 + '8' * num_8)


tt = int(input())
while tt != 0:
	n = int(input())
	eight = (n - 1) // 4 + 1
	nine = n - eight
	print('9' * nine + '8' * eight)
	tt -= 1


def solve():
	pass

def read():
	t = int(input())
	for i in range(t):
		n = int(input())
		no_of_9s = 3 * n // 4
		no_of_8s = n - no_of_9s
		ans = []
		for i in range(no_of_9s):
			ans.append('9')
		for i in range(no_of_8s):
			ans.append('8')
		print(''.join(ans))
read()


for _ in range(int(input())):
	n = int(input())
	d = 0
	if n % 4 == 0:
		d = n // 4
	else:
		d = n // 4 + 1
	for _ in range(0, n - d):
		print('9', end='')
	for _ in range(0, d):
		print('8', end='')
	print()


t = int(input())
for i in range(t):
	x = int(input())
	kol1 = (x + 3) // 4
	print('9' * (x - (x + 3) // 4) + '8' * ((x + 3) // 4))


for i in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	else:
		x = n
		l = ['9'] * n
		while x > 0:
			l[n - 1] = '8'
			n -= 1
			x -= 4
		s = ''.join(l)
		print(int(s))


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def inn():
	return int(input())
t = int(input())
while t:
	t -= 1
	n = int(input())
	if n % 4 == 0:
		res = n // 4
		a = [9] * (n - res) + [8] * res
	else:
		res = n // 4
		a = [9] * (n - res - 1) + [8] * (res + 1)
	print(*a, sep='')


import math
t = int(input())
for q in range(t):
	n = int(input())
	j = n % 4
	for i in range(n - n // 4 - 1):
		print('9', end='')
	if j:
		print('8', end='')
	else:
		print('9', end='')
	for i in range(n // 4):
		print('8', end='')
	print('')


t = int(input())
while t > 0:
	n = int(input())
	q = n // 4
	r = n % 4
	if r == 0:
		arr = [9] * (n - q) + [8] * q
	else:
		arr = [9] * (n - q - 1) + [8] * (q + 1)
	t -= 1
	print(''.join(map(str, arr)))


import sys
import collections
import math

def input():
	return sys.stdin.readline().rstrip()

def split_input():
	return [int(i) for i in input().split()]
tests = int(input())
for _ in range(tests):
	n = int(input())
	s = n - int(math.ceil(n / 4))
	for i in range(s):
		print('9', end='')
	for i in range(s, n):
		print('8', end='')
	print()


import math
for _ in range(int(input())):
	n = int(input())
	temp = math.ceil(n / 4)
	for i in range(n - temp):
		print(9, end='')
	for i in range(temp):
		print(8, end='')
	print()


import math
for _ in range(int(input())):
	n = int(input())
	eights = math.ceil(n / 4)
	print((n - eights) * '9', end='')
	print(eights * '8')


from sys import stdin
from math import ceil
N = int(stdin.readline())
for _ in range(N):
	n = int(stdin.readline())
	eight = ceil(n / 4)
	print('9' * (n - eight) + '8' * eight)


t = int(input())
for i in range(t):
	n = int(input())
	eights = (n + 3) // 4
	nines = n - eights
	print('9' * nines + '8' * eights)


t = int(input())
import math
while t > 0:
	t -= 1
	a = int(input())
	j = math.ceil(a / 4)
	for i in range(a - j):
		print('9', end='')
	for i in range(j):
		print('8', end='')
	print()


import math
for _ in range(int(input())):
	n = int(input())
	if n == 2:
		print('98')
		continue
	if n == 1:
		print(8)
	else:
		y = n / 4
		y = math.ceil(y)
		str = '8' * y
		str += '9' * (n - y)
		str = str[::-1]
		print(str)


ii = lambda : int(input())
import math
for _ in range(ii()):
	n = ii()
	l = math.ceil(n / 4)
	print((n - l) * '9' + l * '8')


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	if n % 4 == 0:
		x = n // 4
	else:
		x = n // 4 + 1
	line = ''
	for i in range(n):
		if i < n - x:
			line += '9'
		else:
			line += '8'
	ans.append(line)
for i in ans:
	print(i)


t = int(input())
for i in range(t):
	n = int(input())
	t = (n - 1) // 4
	for j in range(n - t - 1):
		print(9, end='')
	print(8, end='')
	for j in range(t):
		print(8, end='')
	print()


from math import ceil
from queue import LifoQueue

def print_sol(c, sol):
	print('Case #{}: {}'.format(c, sol))

def rd_int():
	return int(input())

def rd_str():
	return input()

def rd_str_lst():
	return input().split(' ')

def sp_str_lst():
	return list(input())

def rd_int_lst():
	return [int(i) for i in rd_str_lst()]

def sp_int_lst():
	return [int(i) for i in sp_str_lst()]

def dfs(g, i, v):
	v[i] = True
	for j in g[i]:
		if not v[j]:
			dfs(g, j, v)
	print(i)

def dfs_iter(g, i, n):
	v = [False] * n
	stack = LifoQueue()
	stack.put(i)
	while stack.not_empty:
		u = stack.get()
		v[u] = True
		print(u)
		for i in g[u]:
			if not v[i]:
				stack.put(i)

def main():
	t = rd_int()
	for c in range(1, t + 1):
		n = rd_int()
		sol = [0] * n
		e = ceil(n / 4)
		for i in range(n - e):
			sol[i] = 9
		for i in range(n - e, n):
			sol[i] = 8
		print(*sol, sep='')
main()


from math import ceil

def solution():
	n = int(input())
	eight_cnt = int(ceil(n / 4))
	nine_cnt = n - eight_cnt
	answer = '9' * nine_cnt + '8' * eight_cnt
	print(answer)
t = int(input())
for _ in range(t):
	solution()


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s)
	sys.stdout.write('\n')

def wi(n):
	sys.stdout.write(str(n))
	sys.stdout.write('\n')

def wia(a, sep=' '):
	sys.stdout.write(sep.join([str(x) for x in a]))
	sys.stdout.write('\n')

def solve(n):
	k = (n + 3) // 4
	return '9' * (n - k) + '8' * k
	best_r = 0
	best_x = ''
	for eights in range(1, n + 1):
		x = '9' * (n - eights) + '8' * eights
		k = ''.join([format(int(si), 'b') for si in x])
		if len(k) <= n:
			continue
		r = int(k[:-n], 2)
		if r > best_r:
			best_r = r
			best_x = x
	return best_x

def main():
	for _ in range(ri()):
		n = ri()
		ws(solve(n))
main()


from math import *
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print('8')
	elif n == 2:
		print('98')
	else:
		k = (n + 3) // 4
		print('9' * (n - k) + '8' * k)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		et = n // 4
		r = n % 4
		back = '8' * et
		if r != 0:
			back += '8'
		rem = n - et
		if r:
			rem -= 1
		front = '9' * rem
		print(front + back)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		a = n // 4
	else:
		a = n // 4 + 1
	for i in range(n - a):
		print(9, end='')
	for i in range(a):
		print(8, end='')
	print()


t = int(input())
import math
for _ in range(t):
	n = int(input())
	x = math.ceil(n / 4)
	l = ['9'] * (n - x) + ['8'] * x
	print(''.join(l))


t = int(input())
for tt in range(t):
	n = int(input())
	if n % 4 == 0:
		k = n // 4
	else:
		k = n // 4 + 1
	x = ['9'] * (n - k)
	y = ['8'] * k
	p = x + y
	print(''.join(p))


from math import *
for _ in range(int(input())):
	n = int(input())
	if n % 4 != 0:
		x = n // 4 + 1
	else:
		x = n // 4
	res = '9' * (n - x) + '8' * x
	print(int(res))


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	n = int(input())
	k = (n - 1) // 4 + 1
	print('9' * (n - k) + '8' * k)


try:
	import sys
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except BaseException:
	pass
import math
t = int(input())
for _ in range(t):
	n = int(input())
	x = math.ceil(n / 4)
	print('9' * (n - x) + '8' * x)


for s in [*open(0)][1:]:
	n = int(s)
	k = 0 - -n // 4
	print('9' * (n - k) + '8' * k)


from math import *

def main():
	test = int(input())
	for _ in range(test):
		n = int(input())
		e_n = ceil(n / 4)
		n_n = n - e_n
		print(n_n * '9' + '8' * e_n)
main()


t = int(input())
while t:
	n = int(input())
	check = (n - 1) // 4
	check += 1
	for i in range(n - check):
		print(9, end='')
	for i in range(check):
		print(8, end='')
	print()
	t -= 1


import sys
input = sys.stdin.buffer.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
test = inp()
while test != 0:
	test = test - 1
	n = inp()
	_8 = (n + 3) // 4
	_9 = n - _8
	ans1 = '9' * _9
	ans2 = '8' * _8
	print(ans1 + ans2)


t = int(input())
while t:
	t -= 1
	n = int(input())
	if n % 4 == 0:
		res = n // 4
		x = [9] * (n - res)
		y = [8] * res
		a = x + y
	else:
		res = n // 4
		x = [9] * (n - res - 1)
		y = [8] * (res + 1)
		a = x + y
	print(*a, sep='')


production = True
import sys, math, collections, bisect, itertools, heapq, decimal, random, copy, re

def input(f=0, m=0):
	if m > 0:
		return [input(f) for i in range(m)]
	else:
		l = sys.stdin.readline()[:-1]
		if f >= 10:
			u = False
			f = int(str(f)[-1])
		else:
			u = True
		if f == 0:
			p = [l]
		elif f == 1:
			p = list(map(int, l.split()))
		elif f == 2:
			p = list(map(float, l.split()))
		elif f == 3:
			p = list(l)
		elif f == 4:
			p = list(map(int, list(l)))
		elif f == 5:
			p = l.split()
		return p if u else p[0]

def out(l, f=0, n=True):
	if f == 0:
		p = str(l)
	elif f == 1:
		p = ' '.join(map(str, l))
	elif f == 2:
		p = '\n'.join(map(str, l))
	elif f == 3:
		p = ''.join(map(str, l))
	print(p, end='\n' if n else '')

def log(*args):
	if not production:
		print('$$$', end='')
		print(*args)
enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)
flip = lambda a: a + 1 & 1

def mapl(i, f=0):
	if f == 0:
		return list(map(int, i))
	elif f == 1:
		return list(map(str, i))
	elif f == 2:
		return list(map(list, i))

def solve():
	n = input(11)
	f = (n - 1) // 4 + 1
	log(f)
	a = '9' * (n - f) + '8' * f
	out(a)
	return
for i in range(input(11)):
	solve()


exec(int(input()) * "a=int(input())-1;print((a-a//4)*'9'+(a//4+1)*'8');")
arr_inp = lambda : list(map(int, input().split()))
sp_inp = lambda : map(int, input().split())
str_inp = lambda : input()


x = int(input())
for i in range(x):
	j = int(input())
	string = (j - int((j + 3) / 4)) * '9' + int((j + 3) / 4) * '8'
	print(string)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
T = inp()
for t in range(T):
	N = inp()
	a = N // 4
	if N % 4 > 0:
		a += 1
	out = '9' * (N - a) + '8' * a
	print(out)


def solve():
	n = int(input())
	if n % 4 == 0:
		s = '9' * (n - n // 4) + '8' * (n // 4)
	else:
		s = '9' * (n - n // 4 - 1) + '8' * (n // 4 + 1)
	print(s)
for _ in range(int(input())):
	solve()


import math
t = int(input())
while t:
	n = int(input())
	x = math.floor((n + 3) / 4)
	for i in range(n - x):
		print(9, end='')
	for i in range(x):
		print(8, end='')
	print()
	t -= 1


def getInts():
	return [int(x) for x in list(input().split())]

def solve():
	[n] = getInts()
	numOf8 = (n - 1) // 4 + 1
	x = int('9' * (n - numOf8) + '8' * numOf8)
	print(x)
[tc] = getInts()
for i in range(tc):
	solve()


for _ in range(int(input())):
	n = int(input())
	point = (n + 3) // 4
	s9 = '9' * (n - point)
	s8 = '8' * point
	print(s9 + s8)


for _ in range(int(input())):
	n = int(input())
	div = int(n / 4)
	if n % 4 != 0:
		div = div + 1
	n -= div
	while n > 0:
		print(9, end='')
		n = n - 1
	for _ in range(div):
		print(8, end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	z = (n + 3) // 4
	x = '9' * (n - z) + '8' * z
	print(x)


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	x = (n + 3) // 4
	print('9' * (n - x) + '8' * x)


tests = int(input())
for t in range(tests):
	n = int(input())
	res = list(str(10 ** n - 1))
	minus = (n - 1) // 4 + 1
	for i in range(minus):
		res[-i - 1] = '8'
	print(''.join(res))


for tc in range(int(input())):
	n = int(input())
	a = int((n + 3) / 4)
	print('9' * (n - a) + '8' * a)


def solve(n):
	if n == 1:
		print(8)
		return
	elif n == 2:
		print(98)
		return
	elif n == 3:
		print(998)
		return
	elif n == 4:
		print(9998)
		return
	rem = n % 4
	quo = n // 4
	num = []
	for i in range(n - quo - 1):
		num.append('9')
	if rem == 0:
		num.append('9')
	else:
		num.append('8')
	for i in range(quo):
		num.append('8')
	print(''.join(num))
	return
t = int(input())
for _ in range(t):
	inp = input().split()
	n = int(inp[0])
	solve(n)


for t in range(int(input())):
	n = int(input())
	l = n + 3 >> 2
	print('9' * (n - l) + '8' * l)


t = int(input())
l = []
x = 0
for i in range(t):
	n = int(input())
	l.append(n)
for j in l:
	x = j // 4
	if j % 4 == 0:
		print('9' * (j - x), end='')
		print('8' * x)
	else:
		print('9' * (j - x - 1), end='')
		print('8' * (x + 1))


import math
for _ in range(int(input())):
	n = int(input())
	x = '8' * int(math.ceil(n / 4))
	y = '9' * (n - int(math.ceil(n / 4)))
	print(y + x)


for i in range(int(input())):
	x = int(input())
	c = x // 4
	if x % 4 == 0:
		print('9' * (x - c) + '8' * c)
	else:
		print('9' * (x - c - 1) + '8' + '8' * c)


for _ in range(int(input())):
	n = int(input())
	s = ''
	if n % 4 == 0:
		p = n // 4
	else:
		p = n // 4 + 1
	print('9' * (n - p) + '8' * p)


for i in range(int(input())):
	n = int(input())
	btw = n * 3 // 4
	print('9' * btw + '8' * (n - btw))


import math
t = int(input())
for i in range(t):
	n = int(input())
	N = '9' * n
	d = int(math.ceil(n / 4))
	N = N[:len(N) - d]
	if len(N) >= 1:
		print(N + '8' * d)
	else:
		print('8' * d)


from sys import stdin, stdout
import math
input = lambda : stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	else:
		n8 = math.ceil(n / 4)
		print('9' * (n - n8), '8' * n8, sep='')


t = int(input())
for i in range(t):
	a = int(input())
	b = a // 4
	if a % 4 == 0:
		print((a - b) * '9' + b * '8')
	else:
		print((a - (b + 1)) * '9' + (b + 1) * '8')


for _ in range(int(input())):
	n = int(input())
	q = n // 4
	r = n % 4
	a = -1
	if r == 0:
		a = q
	else:
		a = q + 1
	print('9' * (n - a) + '8' * a)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	eight = math.ceil(n / 4)
	nine = n - eight
	print('9' * nine, eight * '8', sep='')


from math import *
t = int(input())
while t:
	t = t - 1
	n = int(input())
	z = n // 4
	if n % 4 != 0:
		z += 1
	s1 = '8' * z
	s2 = '9' * (n - z)
	print(int(s2 + s1))


for _ in range(int(input())):
	n = int(input())
	ans = ''
	if n % 4 != 0:
		ans = '9' * (n - (n // 4 + 1)) + '8' * (n // 4 + 1)
	else:
		ans = '9' * (n - n // 4) + '8' * (n // 4)
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
num8List = [0]
cnt = 1
for i in range(1, 10 ** 5 + 10):
	num8List.append(cnt)
	if i % 4 == 0:
		cnt += 1
for _ in range(t):
	n = int(input())
	n8 = num8List[n]
	n9 = n - n8
	print('9' * n9 + '8' * n8)


from math import ceil
for n in range(int(input())):
	s = int(input())
	ct = ceil(s / 4)
	ans = '9' * (s - ct) + '8' * ct
	print(ans)


test = int(input())

def solve():
	n = int(input())
	ans = pow(10, n) - 2
	ans = list(str(ans))
	for i in range((n + 3) // 4 - 1):
		ans[-2 - i] = 8
	print(''.join((str(i) for i in ans)))
while test:
	solve()
	test -= 1


for i in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		print('9' * (n - n // 4) + '8' * (n // 4))
	else:
		print('9' * (n - (n // 4 + 1)) + '8' * (n // 4 + 1))


import sys
input = sys.stdin.readline
t = int(input())
A = [int(input()) for i in range(t)]
for i in range(t):
	n = A[i]
	rl = n * 4 - n
	nine = rl // 4
	print('9' * nine + '8' * (n - nine))


import math
t = int(input())
for i in range(t):
	n = int(input())
	prevans = [8, 98, 998, 9998, 99988]
	if n <= 5:
		print(prevans[n - 1])
	else:
		m = n / 4
		m = math.ceil(m)
		print('9' * (n - m) + '8' * m)


from math import ceil

def run():
	n = int(input())
	num_of_eights = ceil(n / 4)
	print('9' * (n - num_of_eights) + '8' * num_of_eights)
T = int(input())
while T:
	run()
	T -= 1


import math
t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = [9] * n
	if n != 0:
		t1 = n / 4
		t1 = int(math.ceil(t1))
		t2 = n % 4
		p = n - t1
		s = ''
		for i in range(0, p):
			s = s + '9'
		s = s + '8'
		for i in range(p + 1, n):
			s = s + '8'
		s = int(s)
		print(s)
	else:
		s = 0
		print(s)


import math
t = int(input())
while t > 0:
	a = int(input())
	s = ''
	if a == 1:
		s = 8
	else:
		s = '9' * (a - math.ceil(a / 4)) + '8' * math.ceil(a / 4)
	print(s)
	t = t - 1


from math import *
for t in range(int(input())):
	n = int(input())
	eights = ceil(n / 4)
	nines = n - eights
	print(nines * '9' + eights * '8')


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def Golomb(n):
	dp = [0] * (n + 1)
	dp[1] = 1
	for i in range(2, n + 1):
		dp[i] = 1 + dp[i - dp[dp[i - 1]]]
	return dp[1:]

def solve(leftAllowed, leftLast, ix, movesLeft, dp, a):
	if dp[leftAllowed][leftLast][ix] != -1:
		return dp[leftAllowed][leftLast][ix]
	if movesLeft == 0:
		return 0
	res = 0
	if leftLast == 0 and ix > 0 and (leftAllowed > 0):
		res = max(res, solve(leftAllowed - 1, 1, ix - 1, movesLeft - 1, dp, a) + a[ix - 1])
	res = max(res, solve(leftAllowed, 0, ix + 1, movesLeft - 1, dp, a) + a[ix + 1])
	dp[leftAllowed][leftLast][ix] = res
	return dp[leftAllowed][leftLast][ix]
MOD = 1000000007
PMOD = 998244353
T = 1
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	if n % 4 == 0:
		x = n // 4
		print('9' * (n - x) + '8' * x)
	else:
		x = n // 4
		print('9' * (n - x - 1) + '8' * (x + 1))


t = int(input())
for _ in range(t):
	n = int(input())
	s = ''
	ne = 0
	if n % 4 == 0:
		ne = n // 4
	else:
		ne = n // 4 + 1
	for i in range(n - ne):
		s = s + str(9)
	for i in range(ne):
		s = s + str(8)
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	if 3 * n % 4 == 0:
		f = 3 * n // 4
		print('9' * f + (n - f) * '8')
	else:
		f = 3 * n // 4
		print('9' * f + (n - f) * '8')


from math import ceil
for _ in range(int(input())):
	num = int(input())
	if num <= 4:
		print(10 ** num - 2)
	else:
		cnt = ceil(num / 4)
		print((num - cnt) * '9' + cnt * '8')


def ab():
	n = int(input())
	s = ''
	p = n // 4
	for i in range(0, p):
		s = s + '8'
	if n % 4 != 0:
		s = s + '8'
		p += 1
	for i in range(p - 1, n - 1):
		s += '9'
	m = len(s)
	for i in range(m - 1, -1, -1):
		print(s[i], end='')
	print()
for i in range(0, int(input())):
	ab()


from collections import defaultdict
con = 10 ** 9 + 7
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		if N % 4 == 0:
			ans = '9' * int(N * 3 // 4) + '8' * int(N // 4)
			print(ans)
		else:
			val = int(N // 4) + 1
			ans = '9' * (N - val) + '8' * val
			print(ans)
main()


for i in range(int(input())):
	n = int(input())
	c = (n + 3) // 4
	print('9' * (n - c), end='')
	print('8' * c)


def goodstring(s):
	if s <= 4:
		remainder = 1
	else:
		remainder = int(s // 4) + 1
		if s % 4 == 0:
			remainder -= 1
	print(str(9) * (s - remainder) + str(8) * remainder)
t = int(input())
for t_itr in range(t):
	s = int(input())
	goodstring(s)


import sys
max_int = 1000000001
min_int = -max_int
t = int(input())
for _t in range(t):
	n = int(sys.stdin.readline())
	k = (n + 3) // 4
	print('9' * (n - k) + '8' * k)


T = int(input())
for t in range(T):
	n = int(input())
	print(int('9' * (n - (1 + (n - 1) // 4)) + '8' * (1 + (n - 1) // 4)))


from math import *

def solve(n):
	if n == 1:
		return 8
	digits = [9] * n
	for i in range(3 * n // 4, n):
		digits[i] = 8
	return ''.join((str(i) for i in digits))
t = int(input())
for i in range(0, t):
	n = int(input())
	print(solve(n))


import math
t = int(input())
for i in range(t):
	n = int(input())
	n8 = math.ceil(n / 4.0)
	x = '9' * (n - n8)
	x += '8' * n8
	print(x)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	B = 4 * n - n
	for i in range(4, 4 * n + 1, 4):
		if i > B:
			print('8', end='')
		else:
			print('9', end='')
	print()


import math
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	k = math.ceil(n / 4)
	ans = ''
	for i in range(k):
		ans += '8'
	temp = ''
	for i in range(1, n - k + 1):
		temp += '9'
	ans = temp + ans
	ans = int(ans)
	print(ans)


t = int(input())
w = []
for i in range(t):
	n = int(input())
	if n % 4 == 0:
		r = n // 4
		t = 10 ** n - 1 - (10 ** r - 1) // 9
		w.append(t)
	else:
		r = n // 4
		t = 10 ** n - 1 - (10 ** (r + 1) - 1) // 9
		w.append(t)
for i in w:
	print(i)


import math

def solve():
	n = int(input())
	l = [1, 0, 0, 1] * n
	for i in range(n * 4 - n, n * 4):
		l[i] = 0

	def eval(idx):
		return l[i] * 8 + l[i + 1] * 4 + l[i + 2] * 2 + l[i + 3]
	for i in range(0, n * 4, 4):
		d = eval(i)
		if d == 0:
			d = 8
		print(d, end='')
	print()
t = 1
t = int(input())
while t > 0:
	t -= 1
	solve()


import math as mt
for i in range(int(input())):
	z = int(input())
	p = mt.ceil(z / 4)
	print((z - p) * '9' + p * '8')


for w in range(int(input())):
	n = int(input())
	a = n // 4 + int(n % 4 != 0)
	s = '9' * (n - a) + '8' * a
	print(s)


for _ in range(int(input())):
	n = int(input())
	res = '9' * (n - ((n - 1) // 4 + 1)) + '8' * ((n - 1) // 4) + '8'
	print(res)


for t in range(int(input())):
	n = int(int(input()))
	s1 = '0' * n
	q = n // 4
	if n % 4 == 0:
		s1 = '8' * q
		s2 = '9' * (n - q)
		s3 = s2 + s1
	else:
		s1 = '8' * (q + 1)
		s2 = '9' * (n - q - 1)
		s3 = s2 + s1
	print(int(s3))


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		totLagbe = 4 * n - n
		lagbe9 = totLagbe // 4
		res = ''
		res += '9' * lagbe9
		d = 4 * n - len(res) * 4
		if d > 0:
			x = d // 4
			d = d % 4
			res += '8' * x
		if d > 0:
			x = d // 3
			d = d % 3
			res += '4' * x
		if d > 0:
			x = d // 2
			d = d % 2
			res += '2' * x
		res += '1' * d
		print(res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


w = int(input())
for _ in range(w):
	n = int(input())
	x = n // 4
	if n % 4 != 0:
		x += 1
	string = '8' * x
	string = '9' * (n - x) + string
	print(string)


t = int(input())
for tt in range(t):
	n = int(input())
	amount_of_eights = (n - 1) // 4 + 1
	number = (n - amount_of_eights) * '9'
	print(''.join((number, amount_of_eights * '8')))


t = int(input())
dict = {}
for i in range(t):
	n = int(input())
	dict[i] = n
for key in dict.keys():
	if dict[key] // 4 != dict[key] / 4:
		for i in range(dict[key] - dict[key] // 4 - 1):
			print('9', end='')
		for i in range(dict[key] // 4 + 1):
			print('8', end='')
		print()
	else:
		for i in range(dict[key] - dict[key] // 4):
			print('9', end='')
		for i in range(dict[key] // 4):
			print('8', end='')
		print()


t = int(input())
while t:
	t -= 1
	n = int(input())
	eights = int((n + 3) / 4)
	nines = n - eights
	print('9' * nines + '8' * eights)


t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		print(8)
	elif n == 2:
		print(98)
	elif n == 3:
		print(998)
	elif n == 4:
		print(9998)
	else:
		rem = n % 4
		if n % 4 != 0:
			ass = int(n // 4) + 1
		else:
			ass = int(n // 4)
		ni = '9'
		ei = '8'
		ze = '0'
		z = n - ass
		print(ni * z + ei * (n - z))


import sys
import math

def rmv(s, pos, c):
	if pos >= len(s):
		return s
	ans = s[:pos] + c + s[pos + 1:]
	return ans
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = '9' * n
	for i in range(n):
		if (n - i - 1) * 4 >= n:
			continue
		s = rmv(s, i, '8')
	print(s)


def solve():
	n = int(input())
	fr = (n - 1) // 4 + 1
	for i in range(n - fr):
		print(9, end='')
	for i in range(fr):
		print(8, end='')
	print()
t = int(input())
for i in range(t):
	solve()


import math
cases = int(input())
for _ in range(cases):
	num = int(input())
	ceil = math.ceil(num / 4)
	s = '9' * (num - ceil) + '8' * ceil
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	if n % 4 == 0:
		x = n // 4
	else:
		x = n // 4 + 1
	s = '9' * (n - x)
	s += '8' * x
	print(s)


import math
t = int(input())
res = []
for i in range(t):
	n = int(input())
	v = int(math.ceil(n / 4))
	x = '9' * (n - v) + '8' * v
	res.append(x)
for i in res:
	print(i)


n = int(input())
for i in range(n):
	a = int(input())
	c9 = a - int((a - 1) / 4 + 1)
	c8 = a - c9
	print(c9 * '9' + c8 * '8')


from sys import *
t = int(stdin.readline())
while t > 0:
	n = int(stdin.readline())
	if n % 4 == 0:
		zero = n // 4
		ans = (n - zero) * '9' + zero * '8'
	else:
		zero = n // 4
		ans = (n - zero - 1) * '9' + '8' + zero * '8'
	print(ans)
	t -= 1


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		x = -(-N // 4)
		print('9' * (N - x) + '8' * x)
main()


import math

def facts(n):
	ans = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			ans.append(i)
			ans.append(n // i)
	ans = sorted(list(dict.fromkeys(ans)))
	if ans[-1] == n:
		ans = ans[:-1]
	return ans
for _ in range(int(input())):
	n = int(input())
	e = math.ceil(n / 4)
	ans = '9' * (n - e) + '8' * e
	print(ans)


for vishal in range(int(input())):
	n = int(input())
	print('9' * (n - (n + 3) // 4) + '8' * ((n + 3) // 4))


def cal(n):
	l = n
	t = l // 4
	ex = l % 4
	if ex == 0:
		num = '8' * t
	else:
		num = '8' * (t + 1)
	return '9' * (l - len(num)) + num
for i in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	elif n == 2:
		print(98)
	elif n == 3:
		print(998)
	else:
		print(cal(n))


import math
from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	tot = n // 4
	rem = n % 4
	ans = '9' * (n - tot - 1)
	if rem == 0:
		ans += '9'
	else:
		ans += '8'
	ans += '8' * tot
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	(q, r) = divmod(n, 4)
	if r > 0:
		ans = str(9) * (n - q - 1) + str(8) * (q + 1)
	else:
		ans = str(9) * (n - q) + str(8) * q
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	x = n // 4
	x1 = n % 4
	if x == 0:
		ans = '9' * (n - 1) + '8'
	elif x1 == 0:
		ans = '9' * (n - x) + '8' * x
	else:
		ans = '9' * (n - x - 1) + '8' * (x + 1)
	print(ans)


import sys
input = sys.stdin.readline

def inp():
	return int(input())
n = inp()
for _ in range(n):
	i = inp()
	so8 = int((i + 3) / 4)
	so9 = i - so8
	print('9' * so9 + '8' * so8)


t = int(input())
while t > 0:
	n = int(input())
	x = '9' * n
	x = int(x)
	x = str(x)
	if n % 4 != 0:
		x = x[:len(x) - (n // 4 + 1)]
		x += '8' * (n // 4 + 1)
	else:
		x = x[:len(x) - n // 4]
		x += '8' * (n // 4)
	x = int(x)
	print(x)
	t -= 1


t = int(input())
while t:
	n = int(input())
	f = n - n // 4 - (n % 4 > 0)
	for i in range(f):
		print(9, end='')
	for i in range(n - f):
		print(8, end='')
	print()
	t -= 1


t = int(input())

def solution(x):
	if x % 4 == 0:
		return (x - x // 4) * '9' + x // 4 * '8'
	else:
		return (x - (x // 4 + 1)) * '9' + (x // 4 + 1) * '8'
for i in range(t):
	n = int(input())
	print(solution(n))


t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		print(8)
	else:
		num = n // 4
		rem = n % 4
		e = num
		if rem == 1 or rem == 2 or rem == 3:
			e += 1
		ni = n - e
		for _ in range(ni):
			print(9, end='')
		for _ in range(e):
			print(8, end='')
		print()


import sys
read = sys.stdin.readline
write = sys.stdout.write
t = int(read())
for test_case in range(t):
	n = int(read())
	e = n // 4 + (n % 4 != 0)
	for i in range(n - e):
		write('9')
	for i in range(e):
		write('8')
	write('\n')


def main():
	testcase = int(input())
	for _ in range(testcase):
		n = int(input())
		x = (n - 1) // 4
		x += 1
		print('9' * (n - x) + '8' * x)
main()


def mi():
	return map(int, input().split())
from math import ceil
for _ in range(int(input())):
	n = int(input())
	rem = 4 * n - (3 * n - 3 * n % 4 + n)
	t = rem // 4 * '1001' + ''.join(['1', '0', '0', '1'][:rem % 4]) + '0' * n
	print('9' * (3 * n // 4), end='')
	for i in range(0, len(t), 4):
		l = int(t[i:i + 4], 2)
		l = max(l, 8)
		print(l, end='')
	print()


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
for case in range(1, itg() + 1):
	n = itg()
	q = (n - 1 >> 2) + 1
	ans = '9' * (n - q) + '8' * q
	print(ans)


from sys import stdin
input = lambda : stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	print('9' * (3 * n // 4) + '8' * (n - 3 * n // 4))


t = int(input())
while t != 0:
	n = int(input())
	x = int((n + 3) / 4)
	for i in range(n - x):
		print(9, end='')
	for i in range(x):
		print(8, end='')
	t -= 1
	print()


def solve():
	n = int(input())
	ans = list('9' * n)
	d = 0
	cnt = n // 4
	if n % 4 > 0:
		cnt += 1
	ind = n - 1
	while cnt > 0:
		ans[ind] = '8'
		ind -= 1
		cnt -= 1
	print(''.join(ans))
t = int(input())
for _ in range(t):
	solve()
	t -= 1


t = int(input())

def cal(l, comp, ind, counta, countb, n):
	if ind == n:
		print(counta, countb)
	if ind == n and counta == countb:
		return True
	elif ind == n:
		return False
	elif l[ind] < comp:
		return cal(l, l[ind], ind + 1, counta + 1, countb, n)
	else:
		return cal(l, l[ind], ind + 1, counta + 1, countb, n) or cal(l, l[ind], ind + 1, counta, countb + 1, n)
for _ in range(t):
	n = int(input())
	ans = ''
	if n % 4 == 0:
		ans = '8' * (n // 4)
	else:
		ans = '8' * (n // 4 + 1)
	num9 = n - len(ans)
	ans = '9' * num9 + ans
	print(ans)


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	n = getInt()
	if n >= 5:
		nul = (n - 1) // 4
	else:
		nul = 0
	print('9' * (n - 1 - nul) + '8' + '8' * nul)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for _ in range(ii()):
	n = ii()
	print('9' * (n - math.ceil(n / 4)) + '8' * math.ceil(n / 4))


import sys
import math

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	n = iinput()
	m = math.ceil(n / 4)
	ans = '9' * (n - m) + '8' * m
	print(ans)


for _ in range(int(input())):
	n = int(input())
	eig = abs(-n // 4)
	nin = n - eig
	print('9' * nin + '8' * eig)


from sys import stdin
import math
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	t = math.ceil(n / 4)
	print('9' * (n - t), '8' * t, sep='')


for _ in range(int(input())):
	a = int(input())
	print('9' * (a * 3 // 4) + '8' * (a - a * 3 // 4))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
MOD = 1000000007

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	ans = [9] * n
	k = ceil(n / 4)
	ans = [8] * k + [9] * (n - k)
	print(*ans[::-1], sep='')


for _ in range(int(input())):
	x = int(input())
	c = (x + 3) // 4
	print('9' * (x - c) + '8' * c)


import math
t = int(input())
for i in range(t):
	n = int(input())
	m = math.ceil(n / 4)
	x = n - m
	e = ''
	for j in range(x):
		e = e + '9'
	for k in range(m):
		e = e + '8'
	print(e)


def main():
	for i in range(int(input())):
		n = int(input())
		k = n // 4
		if n % 4 != 0:
			k += 1
		number = '9' * (n - k)
		number += '8' * k
		print(number)
main()


import math
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	else:
		s = n // 4
		if n % 4 != 0:
			s += 1
		p = n - s
		a = '9' * p
		b = '8' * s
		ans = a + b
		print(ans)


for _ in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		eights = n // 4
	else:
		eights = n // 4 + 1
	a = '9' * (n - eights)
	b = '8' * eights
	ans = int(a + b)
	print(ans)


import sys, math

def ii():
	return int(input())

def mii():
	return map(int, input().split())

def lmii():
	return list(mii())

def main():
	for _ in range(ii()):
		n = ii()
		if n == 1:
			print(8)
			continue
		ans = (n - (n + 3) // 4) * '9' + (n + 3) // 4 * '8'
		print(ans)
main()


def run():
	import sys
	sys.stdin = open('/home/punit/Documents/Cpp Programs/input.txt', 'r')
	sys.stdout = open('/home/punit/Documents/Cpp Programs/output.txt', 'w')
	from math import ceil, sqrt, floor
for _ in range(int(input())):
	n = int(input())
	total = n // 4
	if n % 4 != 0:
		total += 1
	x = n - total
	ans = '8' * total
	rem = '9' * x
	rem = rem + ans
	print(rem)


for _ in range(int(input())):
	n = int(input())
	k = n // 4 + 1
	if n % 4 == 0:
		k -= 1
	print('9' * (n - k) + '8' * k)


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
input = stdin.readline
letters = ascii_letters[:26]
for _ in range(int(input())):
	n = int(input())
	res = []
	res = ['8'] * (n // 4 + (1 if n % 4 else 0))
	res = ['9'] * (n - len(res)) + res
	print(''.join(res))


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from fractions import Fraction
INF = float('inf')
mod = int(1000000000.0) + 7
for t in range(int(data())):
	n = int(data())
	if n % 4 != 0:
		ans = '9' * (n - n // 4 - 1) + '8' * (n // 4 + 1)
	else:
		ans = '9' * (n - n // 4) + '8' * (n // 4)
	out(ans)


from sys import stdin
input = stdin.readline
INF = 10 ** 9 + 7
MAX = 10 ** 7 + 7
MOD = 10 ** 9 + 7
for Ti in range(int(input().strip())):
	n = int(input().strip())
	e = (n + 3) // 4
	print('9' * (n - e) + '8' * e)


import math, sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	e = math.floor((n + 3) / 4)
	print((n - e) * '9' + e * '8')


from math import *
from collections import *
from random import *
from bisect import *
import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	r = ceil(n / 4)
	re = '9' * (n - r) + '8' * r
	print(re)


from math import ceil

def solv():
	x = int(input())
	j = ceil(x / 4)
	res = '9' * (x - j) + '8' * j
	print(res)
for _ in range(int(input())):
	solv()


import os
from io import BytesIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline

def lii():
	return list(map(int, input().split()))

def ii():
	return int(input())
t = ii()
for _ in range(t):
	n = ii()
	q = n // 4
	r = n % 4
	if r == 0:
		print('9' * (n - q) + '8' * q)
	elif r > 0:
		print('9' * (n - q - 1) + '8' * (q + 1))


import math
import os
import random
import re
import string
from sys import *
from collections import *

def solve():
	for _ in range(int(stdin.readline())):
		n = int(input())
		x = n / 4
		if x == int(x):
			x = int(x)
			print('9' * (n - x) + '8' * x)
		else:
			x = math.ceil(x)
			print('9' * (n - x) + '8' * x)
solve()


t = int(input())
for i in range(t):
	n = int(input())
	num8 = (n - 1) // 4 + 1
	num9 = n - num8
	print('9' * num9 + '8' * num8)


import sys
import os

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
	x

def take_input():
	if os.environ.get('check'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
take_input()
for _ in range(int(input())):
	n = int(input())
	ans = ['9' for i in range(n)]
	N = n % 4
	for i in range(n // 4):
		ans.pop()
	if N:
		ans.pop()
	for _ in range(n // 4):
		ans.append('8')
	if N:
		ans.append('8')
	ans = ''.join(ans)
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	n8s = (n - 1) // 4 + 1
	n9s = n - n8s
	s = n9s * '9' + n8s * '8'
	print(s)
	t -= 1


from math import *
from copy import *
from string import *
from random import *
from sys import stdin, stdout
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
import math
import time
from queue import Queue

def seive(n):
	l = [True]
	l = l * (n + 1)
	for i in range(2, int(sqrt(n)) + 1):
		if l[i] == True:
			val = i * i
			while val < len(l):
				l[val] = False
				val += i
	prime = []
	for i in range(2, len(l)):
		if l[i] == True:
			prime.append(i)
	return prime

def dp(l, i, n, val, ans):
	if i >= n or val < 0:
		return 1000000
	elif val == 0:
		return 0
	else:
		if ans[i] == 1000000:
			ans[i] = min(min(1 + dp(l, i + 1, n, val - l[i], ans), 1 + dp(l, i, n, val - l[i], ans)), dp(l, i + 1, n, val, ans))
		return ans[i]
from queue import Queue

def factors(n):
	l = []
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def check1(s, v, x):
	while True:
		if v not in s:
			return v
		else:
			v -= 1

def check2(s, v, x):
	while True:
		if v not in s:
			return v
		else:
			v += 1

def up(n):
	j = n - 1
	while j > 0:
		if n % j == 0:
			break
		j -= 1
	return j

def fac(n):
	c = 1
	i = 1
	while i <= n:
		c *= i
		i += 1
	return c

def check_happy(n):
	ss = set()
	print(n)
	while n != 1:
		val = n
		s = 0
		print(val)
		while val != 0:
			s += (val % 10) ** 2
			val = val // 10
		print(val)
		print('hi')
		if val in ss:
			return False
		else:
			n = val
			ss.add(n)
	return True

def update(a, b):
	c = 1
	val = a
	while a < b:
		print(c, a)
		c += c
		a += a
	print(1)
	while a > b:
		print()
		a -= val
		c -= 1
	return c
import random as rand

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
from itertools import permutations

def insertion_sort(arr):
	for i in range(len(arr)):
		j = i
		while j > 0:
			if arr[j] < arr[j - 1]:
				temp = arr[j]
				arr[j] = arr[j - 1]
				arr[j - 1] = temp
			j -= 1
	return arr

def quick_sort(arr, low, high):
	i = low
	j = high
	while i < j:
		if arr[i] > arr[low] and arr[j] < arr[low]:
			temp = arr[i]
			arr[i] = arr[j]
			arr[j] = arr[i]
			i += 1
			j -= 1
		elif arr[i] <= arr[low]:
			i += 1
		elif arr[j] >= arr[low]:
			j -= 1
	print(i, j)
	toto = arr[j]
	arr[j] = arr[low]
	arr[low] = toto
	return j

def dodo(arr, low, high):
	if low < high:
		val = quick_sort(arr, low, high)
		dodo(arr, low, val - 1)
		dodo(arr, val + 1, high)
t = int(stdin.readline())
for i in range(t):
	n = int(input())
	val = int(math.ceil(n / 4))
	a = n - val
	s = ''
	while a != 0:
		a -= 1
		s += '9'
	while val != 0:
		val -= 1
		s += '8'
	stdout.write(s + '\n')


for _ in range(int(input())):
	n = int(input())
	if n % 4 != 0:
		s = n // 4 + 1
	else:
		s = n // 4
	ss = '8' * s
	ss = ss + '9' * (n - len(ss))
	for i in range(len(ss) - 1, -1, -1):
		print(ss[i], end='')
	print()


inp = int(input())
for i in range(inp):
	num = int(input())
	str1 = ''
	str2 = ''
	x = num % 4
	if x == 0:
		str1 = '9' * (num - int(num / 4))
		str2 = '8' * int(num / 4)
	else:
		str1 = '9' * (num - int(num / 4) - 1)
		str2 = '8' * (int(num / 4) + 1)
	str3 = str1 + str2
	print(int(str3))


t = int(input())
for i in range(t):
	n = int(input())
	s = ''
	x = int(n / 4)
	if n % 4 != 0:
		x += 1
	for i in range(n - x):
		s += '9'
	for i in range(x):
		s += '8'
	print(s)


import math
tc = int(input())
while tc > 0:
	tc -= 1
	n = int(input())
	val = n / 4
	val = int(math.ceil(val))
	ans = '9' * int(n - val) + '8' * int(val)
	print(ans)


import math
for _ in range(int(input())):
	n = int(input())
	z = math.ceil(n / 4)
	ans = int('9' * (n - z) + '8' * z)
	print(ans)


from math import ceil
for i in range(int(input())):
	a = int(input())
	c = ceil(a / 4)
	b = int('9' * (a - c) + '8' * c)
	print(b)


for i in range(int(input())):
	vstup = int(input())
	deviatky = vstup + -vstup // 4
	osmicky = -(-vstup // 4)
	print('9' * deviatky + '8' * osmicky)


for _ in range(int(input())):
	n = int(input())
	result = '8' * ((n + 3) // 4) + '9' * (n - (n + 3) // 4)
	print(result[::-1])


for _ in range(int(input())):
	n = int(input())
	nu = str(10 ** n - 1)
	re = 0
	if n % 4 == 0:
		re = n // 4
	else:
		re = n // 4 + 1
	if n == 1:
		print(8)
	else:
		ns = '9'
		es = '8'
		print(ns * (n - re) + es * re)


import math

def shrey():
	n = int(input())
	s = math.ceil(n / 4)
	a = n - s
	for i in range(a):
		print(9, end='')
	for i in range(s):
		print(8, end='')
	print()
T = input()
T = int(T)
for q in range(1, T + 1):
	shrey()


t = int(input())
for i in range(t):
	n = int(input())
	a = (n + 3) // 4
	b = '9' * (n - a)
	b += '8' * a
	print(b)


from math import ceil
for _ in range(int(input())):
	n = int(input())
	s = ''
	k = ceil(n / 4)
	for i in range(n - k):
		s += '9'
	if n % 4 != 0:
		s += '8'
	s += '8' * (n // 4)
	print(s)


t = int(input())
while t:
	n = int(input())
	if n == 1:
		print(8)
	elif n % 4 == 0:
		x = n // 4
		print('9' * (n - x), end='')
		print('8' * x)
	else:
		x = int(n // 4) + 1
		print('9' * (n - x), end='')
		print('8' * x)
	t -= 1


exec(int(input()) * "a=int(input())-1;print((a-a//4)*'9'+(a//4+1)*'8');")


a = int(input())
for i in range(a):
	b = int(input())
	for j in range(b - ((b - 1) // 4 + 1)):
		print('9', end='')
	for j in range((b - 1) // 4 + 1):
		print('8', end='')
	print()


t = int(input())
for test in range(t):
	n = int(input())
	if n % 4 != 0:
		no_of_8 = n // 4 + 1
	else:
		no_of_8 = n // 4
	no_of_9 = n - no_of_8
	ans = ''
	for a in range(no_of_9):
		ans += '9'
	for b in range(no_of_8):
		ans += '8'
	print(ans)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	eights = math.ceil(n / 4.0)
	print('9' * (n - eights) + '8' * eights)


import math
T = int(input())
for _ in range(T):
	n = int(input())
	q = math.ceil(n / 4)
	p = n - q
	for i in range(p):
		print('9', end='')
	for i in range(q):
		print('8', end='')
	print()


t = int(input())
for you in range(t):
	n = int(input())
	z = 3 * n // 4
	print(z * '9', end='')
	print((n - z) * '8')


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(m,) = I()
while m:
	m -= 1
	(k,) = I()
	if k % 4 != 0:
		l = k // 4 + 1
	else:
		l = k // 4
	j = k - l
	print(''.join(['9'] * j) + ''.join(['8'] * l))


t = int(input())
s = [1, 0, 0, 1]

def lookup(x):
	if x != [1, 0, 0, 1]:
		return 8
	else:
		return 9
while True:
	if t == 0:
		break
	t -= 1
	n = int(input())
	numofets = int(n / 4)
	if n % 4 != 0:
		numofets += 1
	ans = []
	for i in range(n):
		if i < numofets:
			ans.append('8')
		else:
			ans.append('9')
	ans.reverse()
	print(''.join(ans))


t = int(input(''))
num = []
for i in range(t):
	num.append(int(input('')))
for i in num:
	s = ''
	if i % 4 == 0:
		f = int(i / 4)
	else:
		f = int(i / 4) + 1
	jhm = int(i / 4)
	lft = 4 - i % 4
	for j in range(i):
		s = s + '1001'
	x = s[0:len(s) - i]
	if lft == 4:
		for i in range(f):
			x = x + '1000'
	else:
		for j in range(4 - lft):
			x = x + '0'
		for j in range(jhm):
			x = x + '1000'
	sol = ''
	k = 0
	while k < len(x):
		sol = sol + str(int(x[k:k + 4], 2))
		k = k + 4
	print(sol)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	n_8 = math.ceil(n / 4)
	n_9 = n - n_8
	s = ''
	for i in range(n_9):
		s += '9'
	for i in range(n_8):
		s += '8'
	print(s)


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	trail = n
	num = ''
	for i in range(n):
		if trail > 0:
			num += '8'
			trail = max(0, trail - 4)
		else:
			num += '9'
	print(num[::-1])


II = lambda : input()
JJ = lambda : int(input())
KK = lambda : list(map(int, input().split()))
from math import ceil
for _ in range(JJ()):
	n = JJ()
	print('9' * (n - ceil(n / 4)) + '8' * ceil(n / 4))


def solution(N):
	newlen = 3 * N
	count_nines = newlen // 4
	count_eights = N - count_nines
	return '9' * count_nines + '8' * count_eights
t = int(input())
for _ in range(t):
	n = int(input())
	s = solution(n)
	print(s)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n,) = I()
	k = n // 4 + int(not n % 4 == 0)
	print('9' * (n - k) + '8' * k)


import sys
input = sys.stdin.buffer.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	c8 = (n - 1) // 4
	c8 += 1
	print('9' * (n - c8) + '8' * c8)


T = int(input())
for t in range(T):
	n = int(input())
	(d, rem) = divmod(n, 4)
	if rem:
		d += 1
	res = '9' * (n - d) + '8' * d
	print(res)


n_tests = int(input())
for i in range(n_tests):
	n_digits = int(input())
	res = ''
	n_eights = n_digits // 4 + 1
	if not n_digits % 4:
		n_eights -= 1
	for i in range(n_digits - n_eights):
		res += '9'
	for i in range(n_eights):
		res += '8'
	print(res)


import math
T = int(input())
for _ in range(T):
	n = int(input())
	x = math.ceil(n / 4)
	if x <= 1:
		p = 2
	else:
		l = ['1'] * (x - 1)
		l.append('2')
		s = ''
		p = int(s.join(l))
	print(10 ** n - p)


def solve(n):
	k = (n - 1) // 4 + 1
	return '9' * (n - k) + '8' * k

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		print(solve(n))
main()


import sys
input = sys.stdin.readline

def inp():
	return int(input())
t = inp()
for i in range(t):
	n = inp()
	n_8 = (n - 1) // 4 + 1
	mystr = ''
	for i in range(n - n_8):
		mystr += str(9)
	for i in range(n_8):
		mystr += str(8)
	print(int(mystr))


t = int(input())
for tst in range(t):
	n = int(input())
	s = ''
	if n % 4 == 0:
		k = int(n / 4)
	else:
		k = int(n / 4) + 1
	s += '9' * (n - k)
	s += '8' * k
	print(s)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class union_find:

	def __init__(self, n):
		self.n = n
		self.rank = [0] * n
		self.parent = [int(j) for j in range(n)]

	def union(self, i, j):
		i = self.find(i)
		j = self.find(j)
		if self.rank[i] == self.rank[j]:
			self.parent[i] = j
			self.rank[j] += 1
		elif self.rank[i] > self.rank[j]:
			self.parent[j] = i
		else:
			self.parent[i] = j

	def find(self, i):
		temp = i
		if self.parent[temp] != temp:
			self.parent[temp] = self.find(self.parent[temp])
		return self.parent[temp]
from math import log2, ceil

def main():
	for t in range(int(input())):
		n = int(input())
		m = (n + 3) // 4
		print('9' * (n - m) + '8' * m)
main()


t = int(input())
for aSRD in range(t):
	n = int(input())
	s = '8' * ((n + 3) // 4)
	s = '9' * (n - len(s)) + s
	print(s)


import sys
t = int(sys.stdin.readline().strip())
for _ in range(t):
	n = int(sys.stdin.readline().strip())
	answ = [9] * n
	zeros = n // 4
	for i in range(zeros):
		answ[n - 1 - i] = 8
	if n % 4 == 0:
		pass
	else:
		answ[n - 1 - zeros] = 8
	print(''.join([str(el) for el in answ]))


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
arr = [6, 10, 14, 1]
for _ in range(I()):
	n = I()
	e = (n + 3) // 4
	print('9' * (n - e), '8' * e, sep='')


from math import ceil
for _ in range(int(input())):
	n = int(input())
	eight = ceil(n / 4)
	nines = n - eight
	ans = ''.join(nines * ['9'] + eight * ['8'])
	print(ans)


from sys import stdin
import math
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	last = math.ceil(n / 4)
	first = n - last
	s = '9' * first + '8' * last
	print(s)


from math import ceil
res = []
for t in range(int(input())):
	n = int(input())
	ei = ceil(n / 4)
	ni = n - ei
	res.append(ni * '9' + ei * '8')
print(*res)


class Main:

	def main(self):
		t = int(input())
		for t1 in range(0, t):
			n = int(input())
			d = (n - 1) // 4 + 1
			result = '9' * (n - d) + '8' * d
			print('{0}'.format(result))
Main().main()


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	n = int(input())
	print('9' * (n - (n + 3) // 4) + '8' * ((n + 3) // 4))
	return
for t in range(int(ii())):
	solve()


import math
T = int(input())
while T > 0:
	N = int(input())
	initial = ['9'] * N
	remove = math.ceil(N / 4)
	initial[len(initial) - remove:] = ['8'] * remove
	print(int(''.join(initial)))
	T -= 1


a = int(input())
for i in range(a):
	s = int(input())
	temp = []
	for i in range(s):
		temp.append(9)
	r = s // 4
	q = s % 4
	j = len(temp) - 1
	while r:
		temp[j] = 8
		j -= 1
		r -= 1
	if q == 0:
		print(''.join(map(str, temp)))
	else:
		if temp[j] == 8:
			j -= 1
			temp[j] = 8
		else:
			temp[j] = 8
		print(''.join(map(str, temp)))


import math
t = int(input())
for i in range(t):
	n = int(input())
	a = (n + 3) // 4
	b = n - a
	ans = b * '9' + a * '8'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	if n % 4:
		binary = ('1001' * n)[:-n] + '0' * (n % 4) + '1000' * (n // 4)
	else:
		binary = ('1001' * n)[:-n] + '1000' * (n // 4)
	l = len(binary) // 4
	s = ''
	for i in range(l):
		s += str(int(binary[4 * i:4 * (i + 1)], 2))
	print(int(s))


t = int(input())
for i in range(t):
	n = int(input())
	a = (n - 1) // 4 + 1
	lis = [9] * (n - a)
	for i in range(a):
		lis.append(8)
	print(''.join((str(i) for i in lis)))


from math import *
t = int(input())
for i in range(t):
	n = int(input())
	x = int(ceil(n / 4))
	ans = '9' * (n - x) + '8' * x
	print(ans)


import sys

def main():
	T = int(sys.stdin.readline())
	for t in range(T):
		n = int(sys.stdin.readline())
		a = (n + 3) // 4
		c = n - a
		print('9' * c + '8' * a)
main()


for _ in range(int(input())):
	n = int(input())
	x = (n + 3) // 4
	for _ in range(n - x):
		print(9, end='', sep='')
	for _ in range(x):
		print(8, end='', sep='')
	print('\n', end='')


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
import math
for _ in range(ii()):
	n = ii()
	l = math.ceil(n / 4)
	print((n - l) * '9' + l * '8')


for testcases in range(int(input())):
	a = int(input())
	x = a // 4
	c = a % 4
	m = a - x
	if c == 0:
		s = '9' * m + '8' * x
	else:
		s = '9' * (m - 1) + '8' + '8' * x
	print(s)


def decimalToBinary(n):
	return bin(n).replace('0b', '')
for _ in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		a = n // 4
	else:
		a = n // 4 + 1
	x = int((a - 1) * '1' + str(2))
	print(10 ** n - x)


for t in range(int(input())):
	n = int(input())
	bitlen = n * 4
	fullgroups = n // 4
	rem = n % 4
	front = n - fullgroups - 1
	ans = '9' * front + ('9' if rem == 0 else '8') + '8' * fullgroups
	print(ans)


import sys
input = sys.stdin.readline

def ceil(x, y):
	if x // y == x / y:
		return x // y
	else:
		return x // y + 1

def main():
	for test_case in range(int(input())):
		n = int(input())
		x = ceil(n, 4)
		res = '9' * (n - x) + '8' * x
		print(res)
	return
main()
pass


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	ans = []
	for i in range(n):
		if i * 4 + 1 <= n:
			ans.append('8')
		else:
			ans.append('9')
	ans.reverse()
	print(''.join(ans))


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			high = mid
		else:
			low = mid + 1
	return low

def check(time, x, y, n):
	time -= min(x, y)
	if time < 0:
		return False
	return time // x + time // y + 1 >= n
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	n = int(input())
	print('9' * (3 * n // 4) + '8' * (n - 3 * n // 4))
for _ in range(int(input())):
	solve()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	q = (n + 3) // 4
	for i in range(q):
		ans.append('8')
	for i in range(n - q):
		ans.append('9')
	ans.reverse()
	print(''.join(ans))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
from types import GeneratorType

def bootstrap(func, stack=[]):

	def wrapped_function(*args, **kwargs):
		if stack:
			return func(*args, **kwargs)
		else:
			call = func(*args, **kwargs)
			while True:
				if type(call) is GeneratorType:
					stack.append(call)
					call = next(call)
				else:
					stack.pop()
					if not stack:
						break
					call = stack[-1].send(call)
			return call
	return wrapped_function
for _ in range(int(ri())):
	n = int(ri())
	temp = ceil(n / 4)
	s = '9' * (n - temp) + '8' * temp
	print(s)


T = int(input())
while T > 0:
	l = int(input())
	need = l // 4
	if l % 4 != 0:
		need += 1
	res = '9' * (l - need) + '8' * need
	print(res)
	T -= 1


t = int(input())
a = [0]
c = 1
for i in range(1, 10 ** 5 + 10):
	a.append(c)
	if i % 4 == 0:
		c += 1
for _ in range(t):
	n = int(input())
	x = a[n]
	y = n - x
	print('9' * y + '8' * x)


for test in range(int(input())):
	n = int(input())
	c = (n + 3) // 4
	print('9' * (n - c) + '8' * c)


q = int(input())
for t in range(q):
	n = int(input())
	m = (n + 3) // 4
	print('9' * (n - m) + m * '8')


import math
t = int(input())
for tt in range(t):
	n = int(input())
	if n == 1:
		print(8)
	else:
		s = ''
		p = int((n + 3) / 4)
		for i in range(n - p):
			print(9, end='')
		for i in range(p):
			print(8, end='')
		print()


import math as m
for i in range(int(input())):
	n = int(input())
	k = m.ceil(n / 4)
	z = n - k
	print('9' * z + '8' * k)


for _ in range(int(input())):
	n = int(input())
	eight = n // 4
	if n % 4 != 0:
		eight += 1
	print('9' * (n - eight), '8' * eight, sep='')


import math
t = int(input())
ans = []

def solve(n):
	length = 3 * n
	ans = '9' * (length // 4)
	while len(ans) < n:
		ans += '8'
	return ans
for i in range(t):
	n = int(input())
	ans.append(solve(n))
for test in ans:
	print(test)


t = int(input())
for _ in range(t):
	n = int(input())
	if n // 4 == n / 4:
		l = n // 4
		print(int((n - l) * '9' + l * '8'))
	else:
		l = n // 4 + 1
		print(int((n - l) * '9' + l * '8'))


import math
t = int(input())
for i in range(t):
	n = int(input())
	s = ''
	m = math.ceil(n / 4)
	for j in range(n - m):
		s = s + '9'
	for j in range(m):
		s = s + '8'
	print(s)


t = int(input())
from math import ceil
for _ in range(t):
	n = int(input())
	if n == 1:
		print(8)
	else:
		x = ceil(n / 4)
		st = '9' * (n - x) + '8' * x
		print(st)


import math
for test in range(int(input())):
	n = int(input())
	count = math.ceil(n / 4)
	ans = '8' * count
	ans = '9' * (n - count) + ans
	print(ans)


import sys, itertools
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	st = []
	for i in range(n):
		st.append(9)
	if n % 4 == 0:
		idx = n // 4
		for i in range(idx):
			st[i] = 8
	else:
		idx = n // 4
		for i in range(idx + 1):
			st[i] = 8
	st.reverse()
	print(''.join(map(str, st)))


for t in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		re = n // 4
		print(int('9' * (n - re) + '8' * re))
	else:
		re = n // 4 + 1
		print(int('9' * (n - re) + '8' * re))


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
MOD = 998244353
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	ans = n // 4 + (1 if n % 4 != 0 else 0)
	print((n - ans) * '9' + ans * '8')


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n // i
	if n > 2:
		l.append(n)
	return l
for _ in range(t):
	n = int(stdin.readline())
	if n % 4 == 0:
		k = n // 4
		n -= k
		print('9' * n + '8' * k)
	else:
		k = n // 4
		k += 1
		n -= k
		print('9' * n + '8' * k)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
for _ in range(L()[0]):
	n = L()[0]
	x = n // 4 + (n % 4 != 0)
	print('9' * (n - x) + '8' * x)


import math
t = int(input())
for i in range(t):
	n = int(input())
	a = int(math.ceil(n / 4))
	ans = ''
	for z in range(n - a):
		ans += '9'
	for z in range(a):
		ans += '8'
	print(ans)


nnn = int(input())
for _ in range(nnn):
	n = int(input())
	k = (n - 1) // 4 + 1
	ans1 = ['9'] * (n - k)
	ans2 = ['8'] * k
	print(''.join(ans1), ''.join(ans2), sep='')


from sys import stdin, stdout
import math
from collections import defaultdict

def print(o):
	return stdout.write(str(o) + '\n')
for _ in range(int(input())):
	n = int(input())
	b = n // 4
	c = n % 4
	ans = ''
	if c != 0:
		ans = (n - b - 1) * '9' + '8' + b * '8'
	else:
		ans = (n - b - 1) * '9' + '9' + b * '8'
	print(ans)


from math import ceil
t = int(input())
for _ in range(t):
	n = int(input())
	check = ceil(n / 4)
	temp = '9' * (n - check) + '8' * check
	print(int(temp))


from math import ceil
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	elif n < 4:
		ans = '8'
		while n > 1:
			ans = '9' + ans
			n -= 1
		print(ans)
	else:
		eis = ceil(n / 4)
		nei = n - eis
		ans = '9' * nei + '8' * eis
		print(ans)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def solution():
	for j in range(Int()):
		n = Int()
		v = ceil(n / 4)
		ans = '9' * (n - v) + '8' * v
		print(ans)
solution()


for _ in range(int(input())):
	n = int(input())
	x = (n - 1) // 4
	x += 1
	s = '9' * (n - x) + '8' * x
	print(s)


for i in range(int(input())):
	n = int(input())
	x = ''
	p = (n * 4 - n) // 4
	for j in range(p):
		x += '9'
	for j in range(n - len(x)):
		x += '8'
	x = int(x)
	print(x)


import math
t = int(input())
n_arr = [int(input()) for i in range(t)]
for n in n_arr:
	num = []
	bin_len = n * 4
	bin_len -= n
	dec_len = bin_len // 4
	chopped = math.ceil(n / 4)
	for i in range(dec_len):
		num.append('9')
	for i in range(chopped):
		num.append('8')
	print(''.join(num))


import math
a = []
for i in range(int(input())):
	n = int(input())
	ans = ''
	eights = math.ceil(n / 4)
	ans = '9' * (n - eights)
	ans += '8' * eights
	print(ans)


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	n = int(inputi())
	n8 = (n - 1) // 4 + 1
	print('9' * (n - n8) + '8' * n8)

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


t = int(input())
for test_case in range(t):
	n = int(input())
	eights = (n + 3) // 4
	ans = '9' * (n - eights) + '8' * eights
	print(ans)


for _t in range(int(input())):
	n = int(input())
	s = 1 + (n - 1) // 4
	print((n - s) * '9', s * '8', sep='')


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		z = n // 4 if n % 4 == 0 else n // 4 + 1
		print((n - z) * '9' + z * '8')
main()


t = int(input())
while t > 0:
	n = int(input())
	if n == 1:
		print('8')
	else:
		x = n // 4
		h = (4 * n - n) % 4
		l = 0
		if h != 0:
			l = 1
		ni = n - l - x
		a = []
		for i in range(ni):
			a.append(9)
		if h != 0:
			a.append(8)
		if x != 0:
			for i in range(x):
				a.append(8)
		print(''.join(map(str, a)))
	t = t - 1


for i in range(int(input())):
	n = int(input())
	n8 = (n + 4 - n % 4) // 4
	if n % 4 == 0:
		n8 = n // 4
	ans = '9' * (n - n8)
	ans += '8' * n8
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	n = int(input())
	x = (n - 1) // 4
	print((n - x - 1) * '9' + (x + 1) * '8')


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from math import ceil
for _ in range(int(read())):
	n = int(read())
	BUFF = ceil(n / 4)
	for i in range(n - BUFF):
		print(9, end='')
	for i in range(BUFF):
		print(8, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	if n < 5:
		print(10 ** n - 2)
	else:
		k = (n + 3) // 4
		print('9' * (n - k) + k * '8')


for _ in range(0, int(input())):
	n = int(input())
	f = -(-n // 4)
	o = n - f
	print('9' * o + '8' * f)


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	p = n
	l = ''
	c = 0
	while n > 0:
		if n <= 4:
			l = l + '8'
			c = c + 1
			break
		else:
			n = n - 4
			l = l + '8'
			c = c + 1
	s = ''
	for i in range(p, c, -1):
		s = s + '9'
	ans = s + l
	print(ans)


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	n = sInt()
	if n == 1:
		print('8')
	else:
		print('9' * (n - (n + 3) // 4) + '8' * ((n + 3) // 4))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	n_eights = math.ceil(n / 4)
	n_nines = n - n_eights
	for i in range(1, n + 1):
		print(9 if i <= n_nines else 8, end='')
	print()


a = int(input())
for i in range(a):
	n = int(input())
	d = n // 4
	l = []
	if n <= 4:
		if n == 1:
			print(8)
		elif n == 2:
			print(98)
		elif n == 3:
			print(998)
		elif n == 4:
			print(9998)
	elif n % 4 != 0:
		for j in range(n - 1, -1, -1):
			if j < d + 1:
				l.append('8')
			else:
				l.append('9')
		ans = int(''.join(l))
		print(ans)
	else:
		for j in range(n - 1, -1, -1):
			if j < d:
				l.append('8')
			else:
				l.append('9')
		ans = int(''.join(l))
		print(ans)


for i in range(int(input())):
	n = int(input())
	x = n // 4 + int(n % 4 > 0)
	ans = '8' * x
	ans = (n - x) * '9' + ans
	print(ans)


T = int(input())
while T != 0:
	T -= 1
	n = int(input())
	digits = 3 * n
	n -= digits // 4
	print(digits // 4 * '9', end='')
	print(n * '8')


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	n = inin()
	l = []
	x = (n + 3) // 4
	for i in range(n - x):
		l.append('9')
	for i in range(x):
		l.append('8')
	print(''.join(l))


TC = int(input())
for tc in range(TC):
	N = int(input())
	rd = -(-N // 4)
	result = []
	for _ in range(N - rd):
		result.append('9')
	for _ in range(rd):
		result.append('8')
	print(''.join(result))


import os
is_dev = 'vscode' in os.environ
if is_dev:
	inF = open('in.txt', 'r')
	outF = open('out.txt', 'w')

def ins(r):
	return list(map(int, r.split(' ')))

def input_():
	if is_dev:
		return inF.readline()[:-1]
	else:
		return input()

def print_(data):
	if is_dev:
		return outF.write(str(data) + '\n')
	else:
		return print(data)
for _ in range(int(input_())):
	n = int(input_())
	s = ''
	for _ in range((n - 1) // 4 + 1):
		s = '8' + s
		n -= 1
	while n > 0:
		s = '9' + s
		n -= 1
	print_(s)
if is_dev:
	print(open('out.txt', 'r').read() == open('outactual.txt', 'r').read())


t = int(input())
for i in range(t):
	n = int(input())
	if n == 1:
		print(8)
		continue
	num_9 = int(3 * n / 4)
	s = num_9 * '9' + (n - num_9) * '8'
	s = int(s)
	print(s)


for test in range(int(input())):
	n = int(input())
	print('9' * (n - (n - 1) // 4 - 1) + '8' * ((n - 1) // 4 + 1))


def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		k = ['1', '0', '0', '1'] * N
		cnt = 0
		i = -1
		while cnt != N:
			if i % 4 != 0:
				k[i] = '0'
			cnt += 1
			i -= 1
		ans = ''
		for i in range(3, len(k), 4):
			binNum = k[i - 3] + k[i - 2] + k[i - 1] + k[i]
			if binNum == '1001':
				ans += '9'
			else:
				ans += '8'
		print(ans)
main()


from math import ceil
for _ in range(int(input())):
	n = int(input())
	a = (n + 3) // 4
	print('9' * (n - a) + '8' * a)


cases = int(input())
for t in range(cases):
	n = int(input())
	v = n // 4
	if n % 4 == 0:
		v = v - 1
	print((n - v - 1) * '9' + (v + 1) * '8')


for t in range(int(input())):
	n = int(input())
	x = int((n * 4 - n) / 4)
	for i in range(n):
		if i < x:
			print(9, end='')
		else:
			print(8, end='')
	print()


for itr in range(int(input())):
	n = int(input())
	k = 1 + (n - 1) // 4
	print('9' * (n - k), '8' * k, sep='')


import sys
input = sys.stdin.readline
t = int(input())
for case in range(t):
	n = int(input())
	erased = n // 4 + 1 if n % 4 else n // 4
	Ans = '9' * (n - erased) + '8' * erased
	print(int(Ans))


n_sets = int(input())
for _ in range(n_sets):
	n_digits = int(input())
	n8 = n_digits // 4 + int(n_digits % 4 != 0)
	n9 = n_digits - n8
	print('9' * n9 + '8' * n8)


t = int(input())

def solve(n):
	ans = ['9' for _ in range(n)]
	y = (n + 3) // 4
	for i in range(y):
		ans[i] = '8'
	s = ''.join(ans)
	revs = s[::-1]
	return revs
for _ in range(t):
	n = int(input())
	print(solve(n))


from math import ceil

def sol(n):
	e = ceil(n / 4)
	print('9' * (n - e) + '8' * e)
k = int(input())
for i in range(k):
	x = int(input())
	sol(x)


for i1 in range(int(input())):
	n = int(input())
	if n % 4 != 0:
		t = n // 4 + 1
	else:
		t = n // 4
	s = n - t
	print('9' * s, end='')
	print('8' * t)


n = int(input())
for i in range(n):
	x = int(input())
	ans = ''
	for j in range(x - int((x + 3) / 4)):
		print('9', end='')
	for j in range(int((x + 3) / 4)):
		print('8', end='')
	print()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	if n % 4 == 0:
		k = n / 4
	else:
		k = math.ceil(n / 4)
	str = ''
	for i in range(n - 1, -1, -1):
		if k > 0:
			str += '8'
		else:
			str += '9'
		k -= 1
	print(str[::-1])


from math import sin, pi

def main():
	t = int(input())
	pr = [6, 10, 14, 15, 21, 22, 26, 33, 34, 35]
	for c in range(t):
		n = int(input())
		x_8 = n // 4 + (1 if n % 4 != 0 else 0)
		print('9' * (n - x_8) + '8' * x_8)
main()


import io
import os
from collections import Counter, defaultdict, deque

def solve(N):
	numEights = (N + 3) // 4
	return '9' * (N - numEights) + '8' * numEights
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	ans = solve(N)
	print(ans)


def func(n):
	val = (n - 1) // 4 + 1
	while n:
		if n <= val:
			print(8, end='')
		else:
			print(9, end='')
		n -= 1
	print('')
for _ in range(int(input())):
	n = int(input())
	func(n)


import math
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	else:
		k = math.ceil(n / 4)
		print('9' * (n - k) + '8' * k)


import math
l = []
x = int(input())
for i in range(x):
	y = int(input())
	a = 10 ** y - 1
	l.append(a - int(math.ceil(y / 4) * '1'))
for i in l:
	print(i)


for _ in range(int(input())):
	n = int(input())
	(m, r) = divmod(n, 4)
	if r == 0:
		print('9' * (n - m) + '8' * m)
	else:
		print('9' * (n - m - 1) + '8' * (m + 1))


for x in range(int(input())):
	a = int(input())
	if a < 3:
		print(10 ** a - 2)
	else:
		b = int(a / 4 * 3)
		print(int('9' * b + '8' * (a - b)))


t = int(input())
for _ in range(t):
	n = int(input())
	(toDelete, rem) = divmod(n, 4)
	if rem == 0:
		s = '9' * (n - toDelete) + '8' * toDelete
	else:
		s = '9' * (n - toDelete - 1) + '8' * (toDelete + 1)
	print(s)


for _ in range(int(input())):
	n = int(input())
	stringNum = ''
	if n % 4 == 0:
		last_no_of_8 = n // 4
	else:
		last_no_of_8 = n // 4 + 1
	no_of_nines = n - last_no_of_8
	for no in range(no_of_nines):
		stringNum += '9'
	for no in range(last_no_of_8):
		stringNum = stringNum + '8'
	print(stringNum)


for _ in range(int(input())):
	n = int(input())
	es = (n - 1) // 4 + 1
	print(''.join(('9' for _ in range(n - es))) + ''.join(('8' for _ in range(es))))


for test in range(int(input())):
	n = int(input())
	cnt = n // 4
	if n % 4 != 0:
		cnt += 1
	print('9' * (n - cnt) + '8' * cnt)


def ans(n):
	if n % 4 == 0:
		o = n // 4
	else:
		o = n // 4 + 1
	p = n - o
	x = '9' * p + '8' * o
	return x
m = int(input())
for i in range(m):
	n = int(input())
	print(ans(n))


t = int(input())
for z in range(t):
	n = int(input())
	x = (n + 3) // 4
	b = ''
	for i in range(0, n - x):
		b += '9'
	for i in range(x):
		b += '8'
	print(b)


import math
TT = int(input())
while TT:
	NN = int(input())
	QQ = math.ceil(NN / 4)
	print('9' * (NN - QQ) + '8' * QQ)
	TT -= 1


import sys, math
from collections import deque, defaultdict
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def main():
	for _ in range(ii()):
		n = ii()
		x = '9' * (n - math.ceil(n / 4))
		x += '8' * math.ceil(n / 4)
		print(x)
main()


import math, sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	p = math.ceil(n / 4)
	print((n - p) * '9' + p * '8')


import sys
readline = lambda : sys.stdin.readline().strip('\n')
readgen = lambda : map(int, readline().split())
from math import ceil
for _ in range(int(input())):
	n = int(input())
	b = ceil(n / 4)
	a = n - b
	print('9' * a + '8' * b)
quit()
for _ in range(int(input())):
	n = int(input())
	l1 = [6, 10, 14, n - 30]
	flag = l1[-1] > 0 and l1[-1] not in l1[:-1]
	if flag:
		print('YES')
		print(' '.join(map(str, l1)))
		continue
	l1 = [6, 10, 15, n - 31]
	flag = l1[-1] > 0 and l1[-1] not in l1[:-1]
	if flag:
		print('YES')
		print(' '.join(map(str, l1)))
		continue
	print('NO')


for i in range(int(input())):
	a = int(input())
	if a == 1:
		print(8)
	elif a % 4 == 0:
		print('9' * (a - a // 4) + '8' * (a // 4))
	else:
		print('9' * (a - a // 4 - 1) + '8' * (a // 4 + 1))


def min_num(n):
	k = n // 4
	x = n % 4
	if x == 0:
		s = '9' * (n - k) + '8' * k
		return s
	else:
		s = '9' * (n - k - 1) + '8' * (k + 1)
		return s
t = int(input())
for _ in range(t):
	n = int(input())
	print(min_num(n))


import collections as cc
import math as mt
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	temp = mt.ceil(n / 4)
	st = '8' * temp
	st = '9' * (n - temp) + st
	print(st)


t = int(input())
for i in range(t):
	n = int(input())
	c = 10 ** n - 1
	if n % 4 == 0:
		y = n // 4
	else:
		y = n // 4 + 1
	z = 0
	s = str('1' * y)
	s = int(s)
	print(c - s)


rr = lambda : input().strip()
rri = lambda : int(rr())
rrm = lambda : [int(x) for x in rr().split()]
from sys import stdin, stdout, setrecursionlimit

def sol():
	n = rri()
	res = ''
	if n == 1:
		print('8')
		return
	if n == 2:
		print('98')
		return
	z = (n + 4 - 1) // 4
	res = '9' * (n - z) + '8' * z
	print(res)
	return

def main():
	T = rri()
	for t in range(1, T + 1):
		ans = sol()
main()


from os import path
import sys
from heapq import heappush, heappop, heapify
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def b(i):
	return ord(i) - ord('a')
file = 1

def solve():
	for _ in range(ii()):
		n = ii()
		x = ceil(n / 4)
		s = '9' * (n - x) + '8' * x
		print(s)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


test = int(input())
for _ in range(test):
	n = int(input())
	x = n // 4 + 1
	if n % 4 == 0:
		print('9' + '9' * (n - x) + '8' * (x - 1))
	else:
		print('9' * (n - x) + '8' * x)


d = {1: 1, 2: 2, 3: 3, 4: 3, 5: 3, 6: 3, 7: 3, 8: 4, 9: 4}
t = int(input())
for u in range(t):
	n = int(input())
	a = 3 * n // 4
	s = '9' * a
	s += '8' * (n - a)
	print(s)


for I in range(int(input())):
	n = int(input())
	needed = n * 4 - n
	nine = needed // 4
	rem = needed % 4
	for i in range(nine):
		print(9, end='')
	for i in range(n - nine):
		print(8, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	v = 0
	if n % 4 == 0:
		v = n // 4
	else:
		v = n // 4 + 1
	if n == 1:
		print('8')
	else:
		print((n - 1 - (v - 1)) * '9', v * '8', sep='')


import math
import os
import random
import re
import sys
for r in range(int(input())):
	k = int(input())
	print('9' * (k - math.ceil(k / 4)) + '8' * math.ceil(k / 4))


import math
case = int(input())
for i in range(case):
	n = int(input())
	eight = math.ceil(n / 4)
	print((n - eight) * '9' + '8' * eight)


from sys import stdin, stdout
input = lambda : stdin.readline().rstrip('\r\n')
from collections import deque as que, defaultdict as vector
from bisect import bisect as bsearch
from heapq import *
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
INF = float('inf')
power2 = lambda n: n & n - 1 == 0
val = ['0', '1', '10', '11', '100', '101', '110', '111', '1000', '1001']
Testcase = inin()
for Case in range(Testcase):
	n = inin()
	k = n // 4 + 1
	if n % 4 == 0:
		k -= 1
	print('9' * (n - k) + '8' * k)


t = int(input())
for _ in range(t):
	x = int(input())
	m = 0
	if x % 4 == 0:
		m = x // 4
	else:
		m = x // 4 + 1
	ans = '9' * (x - m) + '8' * m
	print(ans)


from sys import stdin
from math import ceil

def mini(n):
	k = ceil(n / 4)
	s1 = '9' * (n - k)
	s2 = '8' * k
	s = s1 + s2
	print(s)

def solution():
	input = stdin.readline
	t = int(input())
	for i in range(t):
		n = int(input())
		mini(n)
solution()


t = int(input())
for i in range(t):
	n = int(input())
	if n % 4 == 0:
		a = n // 4
	else:
		a = n // 4 + 1
	ans = []
	for i in range(n - a):
		ans.append('9')
	for i in range(a):
		ans.append('8')
	print(''.join(ans))


from collections import defaultdict as dd
from collections import Counter as ctr
from sys import stdin, stdout
from math import log, sqrt
from itertools import permutations
from bisect import bisect_left, insort
for i in range(int(stdin.readline().strip())):
	n = int(input())
	p = n // 4
	a = ''
	for i in range(n - p):
		a = a + '9'
	if n // 4 == n / 4:
		for i in range(p):
			a = a + '8'
	else:
		a = a[:-1]
		a = a + '8'
		for i in range(p):
			a = a + '8'
	stdout.write(a + '\n')


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = len(li) - 1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def mex(li):
	check = [0] * 1001
	for i in li:
		check[i] += 1
	for i in range(len(check)):
		if check[i] == 0:
			return i

def sumdigits(n):
	ans = 0
	while n != 0:
		ans += n % 10
		n //= 10
	return ans

def product(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def maxpower(n, k):
	cnt = 0
	while n > 1:
		cnt += 1
		n //= k
	return cnt

def knapsack(li, sumi, s, n, dp):
	if s == sumi // 2:
		return 1
	elif n == 0:
		return 0
	elif dp[n][s] != -1:
		return dp[n][s]
	else:
		if li[n - 1] <= s:
			dp[n][s] = knapsack(li, sumi, s - li[n - 1], n - 1, dp) or knapsack(li, sumi, s, n - 1, dp)
		else:
			dp[n][s] = knapsack(li, sumi, s, n - 1, dp)
		return dp[n][s]
from math import *
from collections import deque
max_steps = 100005
for _ in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		print('9' * (n - n // 4) + '8' * (n // 4))
	else:
		print('9' * (n - n // 4 - 1) + '8' * (n // 4 + 1))


for _ in range(int(input())):
	n = input()
	a = (int(n) - 1) // 4 + 1
	lst = []
	b = str(10 ** int(n) - 1)
	for i in b:
		lst.append(i)
	for i in range(a):
		lst[i] = '8'
	lst = lst[::-1]
	print(''.join(lst))


import math
t = int(input())
nums = []
for i in range(t):
	nums.append(int(input()))
for num in nums:
	quo = math.ceil(num / 4)
	s_8 = '8' * quo
	s_9 = '9' * (num - quo)
	print(s_9 + s_8)


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(n):
	tc = []
	ans = {}
	d = 2
	while d * d <= n:
		if n % d == 0:
			tc.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		tc.append(n)
	for i in tc:
		ans[i] = ans.get(i, 0) + 1
	return ans

def to_zero(n, s):
	lst = s[0]
	ans = []
	for i in range(n):
		if lst == s[i]:
			continue
		elif lst == '0':
			lst = '1'
			ans.append(i)
		else:
			lst = '0'
			ans.append(i)
	if lst == '1':
		ans.append(n)
	return ans
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	else:
		if n % 4 != 0:
			d = n // 4 + 1
			n -= d
		else:
			d = n // 4
			n -= d
		print('9' * n + '8' * d)


try:
	tst = int(input())
	for _ in range(tst):
		n = int(input())
		output = ''
		if n % 4 == 0:
			for i in range(n // 4):
				output = '8' + output
			for i in range(n - n // 4):
				output = '9' + output
		else:
			for i in range(n // 4 + 1):
				output = '8' + output
			for i in range(n - n // 4 - 1):
				output = '9' + output
		print(output)
except:
	pass


t = int(input())
while t > 0:
	t -= 1
	k = int(input())
	a = (k + 3) // 4
	print('9' * (k - a) + '8' * a)


import sys
import math
from collections import Counter
import heapq
try:
	for _ in range(int(input())):
		n = int(input())
		a = ''
		x = n // 4 + (n % 4 != 0)
		a = '9' * (n - x) + '8' * x
		print(a)
except:
	pass


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase

def inp():
	return int(input())

def main():
	testcase = inp()
	for _ in range(testcase):
		n = inp()
		totLagbe = 4 * n - n
		lagbe9 = totLagbe // 4
		res = ''
		res += '9' * lagbe9
		d = 4 * n - len(res) * 4
		if d > 0:
			x = d // 4
			d = d % 4
			res += '8' * x
		if d > 0:
			x = d // 3
			d = d % 3
			res += '4' * x
		if d > 0:
			x = d // 2
			d = d % 2
			res += '2' * x
		res += '1' * d
		print(res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import math
for _ in range(int(input())):
	n = int(input())
	p = math.ceil(n / 4)
	ans = '8' * p
	p = n - len(ans)
	ans1 = '9' * p + ans
	print(int(ans1))


t = int(input())
for _ in range(t):
	n = int(input())
	ans = ['9'] * n
	for i in range((n + 3) // 4):
		ans[-1 - i] = '8'
	print(''.join(ans))


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
for __ in range(int(input())):
	n = int(input())
	ans = ''
	t = 4 * n - n
	rslt = ''
	a = ''
	for i in range(4, 4 * n + 1, 4):
		if i > t:
			rslt += '8'
		else:
			rslt += '9'
	print(rslt)


for _ in range(int(input())):
	m = int(input())
	x = 3 * m // 4
	y = m - 3 * m // 4
	print('9' * x + '8' * y)


import re
t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		print(8)
	elif n == 2:
		print(98)
	elif n == 3:
		print(998)
	elif n == 4:
		print(9998)
	else:
		k = 4
		s = ''
		x = n % k
		e = n // k
		s += '8' * e
		if x == 3:
			s += '8'
		elif x == 2:
			s += '8'
		elif x == 1:
			s += '8'
		curr = len(s)
		s += '9' * (n - curr)
		s = s[::-1]
		print(int(s))


from collections import deque
import sys
import math

def inp():
	return sys.stdin.readline().strip()
for _ in range(int(inp())):
	n = int(inp())
	ln = math.ceil(n / 4)
	print('9' * (n - ln) + '8' * ln)


t = int(input())
for ii in range(t):
	n = int(input())
	ans = '9' * (n - 1) + '8'
	ans = list(ans)
	if n % 4 == 0:
		val = n // 4
		ptr = -1
		for i in range(val):
			ans[ptr] = '8'
			ptr -= 1
	else:
		val = n // 4
		ptr = -1
		for i in range(val):
			ans[ptr] = '8'
			ptr -= 1
		ans[ptr] = '8'
	print(''.join(ans))


for _ in range(int(input())):
	n = int(input())
	eight = (n + 3) // 4
	print(''.join(['9' * (n - eight), '8' * eight]))


for _ in range(int(input())):
	n = int(input())
	s = 0 - -n // 4
	print('9' * (n - s) + '8' * s)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	x = (n + 3) // 4
	ans = ['9' for __ in range(n - x)] + ['8' for ____ in range(x)]
	ans = ''.join(ans)
	print(ans)


def solve():
	n = int(input())
	b = n // 4
	c = n % 4
	out = [8] * b
	if c == 0:
		out.append(9)
	else:
		out.append(8)
	extra = n - b - 1
	out.extend([9] * extra)
	out = list(map(str, reversed(out)))
	print(''.join(out))
t = int(input())
for test in range(t):
	solve()


import bisect
import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		n = iin()
		x = n * 4
		x -= n
		p = x // 4
		s = '9' * p
		x = x % 4
		x += n
		s = s + '8' * (x // 4)
		print(s)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
tc = int(input())
for ctr in range(tc):
	n = int(input())
	x = math.ceil(n / 4)
	for i in range(n - x):
		print(9, end='')
	for i in range(x):
		print(8, end='')
	print()


for tt in range(int(input())):
	n = int(input())
	num = (n + 3) // 4
	val = '9' * (n - num) + '8' * num
	print(val)


import math
t = int(input())
while t:
	t -= 1
	n = int(input())
	temp = math.ceil(n / 4)
	s = '9' * (n - temp) + '8' * temp
	print(s)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	print((n - (n - 1) // 4 - 1) * '9' + ((n - 1) // 4 + 1) * '8')


for t in range(int(input())):
	N = int(input())
	K = (N - 1) // 4
	if N == 1:
		print('8')
	elif N == 2:
		print('98')
	elif N == 3:
		print('998')
	elif N == 4:
		print('9998')
	else:
		print((N - K - 1) * '9' + (K + 1) * '8')


t = int(input())
for i in range(t):
	n = int(input())
	m = (n - 1) // 4 + 1
	k = n - m
	ans = '9' * k + '8' * m
	print(ans)


for _ in range(int(input())):
	n = int(input())
	k = int((n + 3) / 4)
	for __ in range(n - k):
		print(9, end='')
	for __ in range(k):
		print(8, end='')
	print()


n = int(input())
t = []
for i in range(0, n):
	t.append(int(input()))
for i in range(0, n):
	bitlen = t[i] * 3 // 4
	if bitlen == 0:
		print('8')
	else:
		print('9' * bitlen + '8' * (t[i] - bitlen))


from math import ceil
for i in range(int(input())):
	n = int(input())
	e = ceil(n / 4)
	print('9' * (n - e) + '8' * e)


T = int(input())
while T:
	n = int(input())
	c = (n + 3) // 4
	print('9' * (n - c) + '8' * c)
	T = T - 1


for _ in range(int(input())):
	a = int(input())
	z = (a - 1) // 4
	z += 1
	print((a - z) * '9' + '8' * z)


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 1000000007

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def main():
	n = int(input())
	ans = '9' * (n - math.ceil(n / 4))
	if n % 4 == 0:
		ans += '8' * (n - len(ans))
	else:
		ans += '8'
		ans += '8' * (n - len(ans))
	print(ans)
t = int(input())
for _ in range(t):
	main()


for _t in range(int(input())):
	n = int(input())
	s = ['8' for i in range(1 + (n - 1) // 4)]
	while len(s) < n:
		s += '9'
	print(*s[::-1], sep='')


import math
for t in range(int(input())):
	n = int(input())
	eight = math.ceil(n / 4)
	l = ['9'] * (n - eight) + ['8'] * eight
	l = ''.join(l)
	print(l)


t = int(input())
while t:
	n = int(input())
	k = (n - 1) // 4 + 1
	print('9' * (n - k), end='')
	print('8' * k)
	t = t - 1


from sys import stdin, exit, setrecursionlimit
from collections import deque
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
for _ in range(int(input())):
	n = int(input())
	print('9' * (n - (n + 3) // 4) + '8' * ((n + 3) // 4))


T = int(input())
while T != 0:
	n = int(input())
	if n == 1:
		print('8')
	else:
		numof8 = n // 4 + 1
		if n % 4 == 0:
			numof8 -= 1
		ans = ''
		for i in range(n - numof8):
			ans = ans + '9'
		for i in range(numof8):
			ans = ans + '8'
		print(ans)
	T -= 1


from math import ceil

def DTB(n):
	return bin(n).replace('0b', '')
for abcd in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	else:
		x = 0
		temp = ceil(n / 4)
		s = '9' * (n - temp) + '8' * temp
		print(s)


import math

def ans(a):
	for i in range(2, int(math.sqrt(a)) + 1, 1):
		if a % i == 0:
			return False
	return True
t = int(input())
while t > 0:
	a = int(input())
	b = int(a // 4)
	if a % 4:
		b += 1
	a = a - b
	while a > 0:
		print('9', end='')
		a -= 1
	while b > 0:
		print('8', end='')
		b -= 1
	print()
	t -= 1


for _ in range(int(input())):
	N = int(input())
	a = N // 4
	rem = N % 4
	if rem > 0:
		ans = '9' * (N - a - 1)
	else:
		ans = '9' * (N - a)
	if 0 < rem < 4:
		ans += '8'
	print(ans + '8' * a)


t = int(input())
while t > 0:
	n = int(input())
	r = n % 4
	m = int(n / 4)
	if r == 0:
		print(int((n - m) * '9' + m * '8'))
	else:
		print(int((n - m - 1) * '9' + (m + 1) * '8'))
	t -= 1


from sys import stdin
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	print('9' * (n - ((n - 1) // 4 + 1)) + '8' * ((n - 1) // 4 + 1))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		k = 3 * n // 4
		ans = '9' * k + '8' * (n - k)
		print(ans)
	return
main()


def main():
	for _ in range(int(input())):
		n = int(input())
		i = (n + 3) // 4
		print((n - i) * '9' + i * '8')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	if n % 4 == 0:
		a = n // 4
	else:
		a = n // 4 + 1
	s = ['9'] * (n - a) + ['8'] * a
	ans = ''.join(s)
	print(ans)


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	n = inp()
	a = math.ceil(n / 4)
	print('9' * (n - a) + '8' * a)
for _ in range(inp()):
	solve()


from sys import stdin, stdout
import math
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def chars():
	s = cin()
	return list(s[:len(s) - 1])

def pl(a):
	for val in a:
		cout(str(val) + ' ')
	cout('\n')
(t,) = mp()
for _ in range(t):
	(n,) = mp()
	k = math.ceil(n / 4)
	s = '9' * (n - k) + '8' * k
	cout(s)
	cout('\n')


from sys import stdin
T = int(stdin.readline())
for _ in range(T):
	n = int(input())
	res = ''
	l = n // 4
	if n % 4 != 0:
		l += 1
	n = n - l
	res = '9' * n + '8' * l
	print(int(res))


for _ in range(int(input())):
	n = int(input())
	cnt = 0
	t = n
	while t > 4:
		t -= 4
		cnt += 1
	for i in range(n - 1 - cnt):
		print('9', end='')
	print('8', end='')
	for i in range(cnt):
		print('8', end='')
	print('')


x = int(input())
for z in range(x):
	n = int(input())
	if n == 1:
		print(8)
	else:
		c = (n - 1) // 4 + 1
		s = '8' * c
		s1 = '9' * (n - c)
		print(s1 + s)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	if n % 4 == 0:
		x = n // 4
	else:
		x = n // 4 + 1
	ans = '9' * (n - x)
	ans += '8' * x
	print(ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	st = ''
	res = math.ceil(n / 4)
	lik = ['9'] * (n - res)
	for k in range(res):
		lik.append('8')
	print(st.join(lik))


from math import log2, floor
for _ in range(int(input())):
	N = int(input())
	if N % 4 == 0:
		X = N // 4
	else:
		X = N // 4 + 1
	S = '9' * (N - X) + '8' * X
	print(S)


import math
from collections import deque
import sys
sys.setrecursionlimit(10 ** 4)

def Divisors(n):
	l = []
	i = 2
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
		i = i + 1
	return l

def SieveOfEratosthenes(n):
	l = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(n)
	return l

def Factors(n):
	result = []
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if i == n / i:
				result.append(i)
			else:
				result.append(i)
				result.append(n // i)
	result.append(1)
	return result

def maxSubArraySum(a):
	max_so_far = 0
	max_ending_here = 0
	size = len(a)
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < abs(max_ending_here):
			max_so_far = max_ending_here
	return max_so_far

def longestsubarray(arr, n, k):
	current_count = 0
	max_count = 0
	for i in range(0, n, 1):
		if arr[i] % k != 0:
			current_count += 1
		else:
			current_count = 0
		max_count = max(current_count, max_count)
	return max_count

def main():
	n = int(input())
	c = n // 4 + 1
	if n % 4 == 0:
		c -= 1
	for j in range(0, n - c):
		print(9, end='')
	for j in range(0, c):
		print(8, end='')
	print()
t = int(input())
for i in range(0, t):
	main()


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		n = I()
		v = n // 4
		if n % 4 != 0:
			v += 1
		print('9' * (n - v) + '8' * v)
main()


t = int(input())
import math
while t:
	t -= 1
	n = int(input())
	p = math.ceil(n / 4)
	ans = '9' * (n - p) + '8' * p
	print(int(ans))


import sys
import math
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	n = int(input())
	last_8 = math.ceil(n / 4)
	ans = '9' * (n - last_8) + '8' * last_8
	print(ans)


t = input()
t = int(t)
for i in range(t):
	n = input()
	n = int(n)
	d = '1001' * n
	c = len(d) - n
	s = d[:c]
	e = '0' * n
	s = s + e
	q = ''
	j = 0
	while j < len(s):
		if s[j:j + 4] == '1001':
			q = q + '9'
		else:
			q = q + '8'
		j = j + 4
	print(int(q))


import math
t = int(input())
for i in range(t):
	n = int(input())
	r = math.ceil(n / 4)
	c = ['9'] * (n - r)
	d = ['8'] * r
	print(''.join(c) + ''.join(d))


t = int(input())
for ex in range(t):
	n = int(input())
	ei = n // 4 + int(n % 4 != 0)
	ans = str()
	ans += '9' * (n - ei)
	ans += '8' * ei
	print(ans)


tt = int(input())
while tt != 0:
	n = int(input())
	k = '1001' * n
	r = k[:len(k) - n]
	t = n // 4
	m = n % 4
	if m > 0:
		print('9' * (n - t - 1) + '8' * (t + 1))
	else:
		print('9' * (n - t) + '8' * t)
	tt -= 1


import math
t = int(input())
for _ in range(t):
	n = int(input())
	x = '8'
	y = '9'
	d = (n + 3) // 4
	print(y * (n - d), end='')
	print(x * d)


import math
for ii in range(int(input())):
	n = int(input())
	if n <= 4:
		print('9' * (n - 1) + '8' * 1)
	else:
		print('9' * (n - math.ceil(n / 4)) + '8' * math.ceil(n / 4))


import math
test = int(input())
for _ in range(test):
	n = int(input())
	eights = math.ceil(n / 4)
	num_s = '9' * (n - eights) + '8' * eights
	num = int(num_s)
	print(num)


def readn():
	return int(input())

def readlist():
	return list(map(int, input().split()))

def readnos():
	return map(int, input().split())
for _ in range(readn()):
	n = int(input())
	if n % 4 == 0:
		a = n // 4 * '8'
		b = (n - n // 4) * '9'
		print(b + a)
	else:
		a = (n // 4 + 1) * '8'
		b = (n - n // 4 - 1) * '9'
		print(b + a)


import sys, os, time
from math import log, sqrt, floor
from os import path
import math
oj = True
if path.exists('inp.txt'):
	print('YES')
	sys.stdin = open('inp.txt', 'r')
	sys.stdout = open('out.txt', 'w')
	oj = False
mod = 1000000007
INF = float('inf')

def readint():
	return int(sys.stdin.readline())

def readlst():
	return list(map(int, sys.stdin.readline().strip().split()))

def readmul():
	return map(int, sys.stdin.readline().strip().split())

def is_power_two(x):
	return x ^ x - 1 & x == x

def lcm(a, b):
	return a * b // gcd(a, b)

def seive():
	(primes[0], primes[1]) = (False, False)
	for i in range(2, maxN + 1):
		for j in range(i * i, maxN + 1, i):
			if primes[j]:
				primes[j] = False

def power_2(n):
	return 1 << n

def ceil(a, b):
	return int((a + b - 1) / b)

def isPerfectSquare(x):
	if x >= 0:
		sr = sqrt(x)
		return sr * sr == x
	return false

def sol():
	n = readint()
	ans = '9' * n
	target = ''
	l = []
	for i in ans:
		for j in bin(int(i))[2:]:
			l.append(int(j))
	m = len(l)
	for i in range(m - n, m):
		l[i] = 0
	for i in range(0, m, 4):
		ans = l[i:i + 4]
		final = ''
		for k in ans:
			final += str(k)
		tmp = str(int(final, 2))
		if tmp == '0':
			tmp = '8'
		target += tmp
	print(target)
	return

def main():
	tc = readint()
	start = time.time()
	while tc:
		sol()
		tc -= 1
	if not oj:
		total = time.time() - start
		print(str(total * 1000) + 'ms')
main()


n = int(input())
for i in range(n):
	digits = int(input())
	n8 = digits // 4
	if digits % 4 != 0:
		n8 += 1
	total = '9' * (digits - n8) + '8' * n8
	print(total)


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	n = get_int()
	(q, r) = divmod(n, 4)
	if r == 0:
		print('9' * (n - q) + '8' * q)
	else:
		print('9' * (n - q - 1) + '8' * (q + 1))

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


t = int(input())
for cases in range(t):
	n = int(input())
	x = n - 1
	ans = [9] * n
	p = x + 1
	k = int(x / 4)
	for i in range(n - 1 - k, n):
		ans[i] = 8
	res = []
	for item in ans:
		res.append(str(item))
	x = ''.join(res)
	print(int(x))


t = int(input())
for _ in range(t):
	n = int(input())
	x = (n - 1) // 4 + 1
	s = ''
	for i in range(x):
		s += '8'
	a = '9' * (n - x)
	s = a + s
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	a = ''
	a += '9' * (3 * n // 4)
	if 3 * n % 4 != 0:
		a += '8'
	while len(a) != n:
		a += '8' * (n - len(a))
	print(a)


import sys
input = sys.stdin.readline
t = int(input())
a = [0]
count = 1
for i in range(1, 10 ** 5 + 10):
	a.append(count)
	if i % 4 == 0:
		count += 1
for _ in range(t):
	n = int(input())
	temp1 = a[n]
	temp2 = n - temp1
	print('9' * temp2 + '8' * temp1)


for i in range(int(input())):
	n = int(input())
	l = n // 4
	if n % 4 > 0:
		l += 1
	s2 = '8' * l
	s1 = '9' * (n - l)
	s1 += s2
	print(int(s1))


t = int(input())
for i in range(t):
	n = int(input())
	count = n * 3 // 4
	out = count * '9' + (n - count) * '8'
	print(out)


for _ in range(int(input())):
	n = int(input())
	e = n // 4
	if n % 4:
		e += 1
	m = int('9' * (n - e) + '8' * e)
	print(m)


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default='z', func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	else:
		k = int(math.ceil(n / 4))
		print('9' * (n - k) + '8' * k)


for _ in range(int(input())):
	n = int(input())
	if n < 4:
		out = int('9' * (n - 1) + '8' * 1)
	else:
		eights = n // 4
		if n % 4 != 0:
			eights += 1
		out = int('9' * (n - eights) + '8' * eights)
	print(out)


import math
from collections import defaultdict

def solve():
	n = int(input())
	rem = (n - 1) // 4 + 1
	result = ''
	for i in range(rem):
		result += '8'
	while len(result) < n:
		result = '9' + result
	print(result)
t = int(input())
for _ in range(t):
	solve()


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	d = int(math.ceil(n / 4))
	print((n - d) * '9' + d * '8')


t = int(input())
while t:
	n = int(input())
	if n <= 4:
		print(10 ** n - 2)
	else:
		emp = ''
		if n % 4 == 0:
			eights = n // 4
			nines = n - eights
		else:
			eights = n // 4 + 1
			nines = n - eights
		emp += '9' * nines
		emp += '8' * eights
		print(emp)
	t -= 1


from math import ceil
t = int(input())
res = []
for i in range(t):
	n = int(input())
	numofeight = ceil(n / 4)
	sol = '8' * numofeight + '9' * (n - numofeight)
	sol = int(sol[::-1])
	res += [sol]
for i in res:
	print(i)


import math
t = int(input())
for g in range(0, t):
	n = int(input())
	k = math.ceil(n / 4)
	ans = '9' * (n - k) + '8' * k
	print(ans)


n = int(input())
for i in range(n):
	a = int(input())
	x = int((a + 3) / 4)
	res = '9' * int(a - x)
	res += '8' * int(x)
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	r = (n - 1) // 4 + 1
	re = '9' * (n - r) + '8' * r
	print(re)


t = int(input())
for _ in range(t):
	n = int(input())
	a = n // 4
	b = n % 4
	res = '9' * (n - a - 1)
	add = ''
	if b > 0:
		add = '8'
	else:
		add = '9'
	res += str(add)
	res += '8' * a
	print(res)


import os
import operator
import sys
import bisect
import _operator
from _collections import defaultdict
from io import BytesIO, IOBase

def inar():
	return [int(k) for k in input().split()]

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def main():
	for _ in range(int(input())):
		n = int(input())
		ans = '8' * (n // 4)
		rem = n % 4
		if rem != 0:
			ans += '8'
		res = n - n // 4
		if rem > 0:
			res -= 1
		take = '9' * res
		print(take + ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
for _ in range(int(input())):
	n = int(input())
	if n > 5:
		ss = math.ceil(n / 4)
		num = n - ss
		print('9' * num + '8' * ss)
	elif n <= 4:
		print('9' * (n - 1) + '8' * 1)


import sys
for b in range(0, int(sys.stdin.readline())):
	x = int(sys.stdin.readline())
	zero = int(x / 4)
	nine = x - 1 - int((x - 1) / 4)
	eight = int(not x % 4 == 0) + int(x / 4)
	out = '9' * nine + '8' * eight
	sys.stdout.write(out + '\n')


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary_rep(n):
	l = []
	while n > 0:
		l.append(n % 2)
		n = n // 2
	return l
for t in range(int(input())):
	n = int(input())
	answer = []
	for i in range(n):
		answer.append(9)
	for i in range(n // 4 + (1 if n % 4 != 0 else 0)):
		answer[i] = 8
	answer.reverse()
	print(*answer, sep='')


import math
for _ in range(int(input())):
	num = int(input())
	cop = num
	last = []
	d = math.ceil(num / 4)
	print('9' * (num - d) + '8' * d)


t = int(input())
for i in range(0, t):
	m = int(input())
	l = []
	z = int(m / 4)
	if m % 4 != 0:
		z += 1
	for j in range(0, m - z):
		l.append(9)
	for j in range(0, z):
		l.append(8)
	print(*l, sep='')


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		z = (n - 1) // 4
		print('9' * (n - z - 1) + '8' * (z + 1))
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	elif n == 2:
		print(98)
	elif n == 3:
		print(998)
	else:
		x = (n - 1) // 4 + 1
		print('9' * (n - x), end='')
		print('8' * x)


from math import *
for u in range(int(input())):
	n = int(input())
	if n < 4:
		print('9' * (n - 1) + '8')
	else:
		c = ceil(n / 4)
		print('9' * (n - c) + '8' * c)


import math
t = int(input())
for case in range(t):
	n = int(input())
	num_8 = math.ceil(n / 4)
	num_9 = n - num_8
	res = ''
	for i in range(num_9):
		res += '9'
	for i in range(num_8):
		res += '8'
	print(int(res))


t = int(input())
for _ in range(t):
	n = int(input())
	k = (n - 1) // 4 + 1
	q = n - k
	s = '9' * q
	p = '8' * k
	print(s + p)


import math, sys, bisect, heapq
from math import *
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
for _ in range(int(input())):
	N = int(input())
	if N == 1:
		print(8)
	else:
		x = math.ceil(N / 4)
		y = '9' * (N - x)
		print(y + x * '8')


def solve(n):
	x = n + 3
	y = int(x / 4)
	for i in range(n - y):
		print('9', end='')
	for i in range(y):
		print('8', end='')
	print()
t = int(input())
for i in range(t):
	n = int(input())
	solve(n)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	if n % 4 == 0:
		k = int(n / 4)
	else:
		k = int(n / 4) + 1
	z = ''
	x = k
	for i in range(n - k):
		z += '9'
	for i in range(k):
		z += '8'
	print(z)


t = int(input())
for _ in range(t):
	n = int(input())
	tmp = (n * 4 - n) // 4
	print('9' * tmp + '8' * (n - tmp))


t = int(input())
for _ in range(t):
	n = int(input())
	eights = n // 4 + bool(n % 4)
	print('9' * (n - eights), '8' * eights, sep='')


for _ in range(int(input())):
	n = int(input())
	c = n * 3 // 4
	r = '9' * c + '8' * (n - c)
	print(r)


t = int(input())
for _ in range(t):
	n = int(input())
	x = 3 * n
	string = ''
	for i in range(x // 4):
		string += '9'
	for j in range(n - x // 4):
		string += '8'
	print(string)


(z, zz, dgraphs) = (input, lambda : list(map(int, z().split())), {})
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	n = int(z())
	t = n // 4
	k = 1
	if n % 4 == 0:
		k = 0
	f = '9' * (n - t - k)
	l = '8' * (t + k)
	print(f + l)


import math

def solve(n):
	if n == 1:
		return 8
	eight = math.ceil(n / 4)
	s = ''
	for i in range(n - eight):
		s += '9'
	s = s + '8' * eight
	return int(s)
t = int(input())
for _ in range(t):
	n = int(input())
	print(solve(n))


import math
for _ in range(int(input())):
	n = int(input())
	ans = ''
	p = n // 4
	if n % 4 > 0:
		p += 1
	ans += '9' * (n - p)
	ans += '8' * p
	print(int(ans))


import sys
from math import sqrt, gcd, ceil, log
from collections import defaultdict, Counter, deque
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))

def main():
	ans = []
	for _ in range(int(input())):
		n = int(input())
		m = n // 4 + [0, 1][n % 4 > 0]
		s = '9' * (n - m) + '8' * m
		print(s)
main()


for _ in range(int(input())):
	n = int(input())
	n1 = n
	c = 0
	s = ''
	count = 0
	while n1 >= 4:
		count += 1
		s += '8'
		n1 -= 4
	if n1 == 1 or n1 == 2 or n1 == 3:
		s += '8'
		count += 1
	for i in range(n - count):
		s += '9'
	s = s[::-1]
	print(s)


import math
for _ in range(int(input())):
	x = int(input())
	a = (x + 3) // 4
	for i in range(x - a):
		print('9', end='')
	for i in range(a):
		print('8', end='')
	print()


import sys
from math import ceil
input = sys.stdin.buffer.readline

def print(val):
	sys.stdout.write(val + '\n')

def prog():
	for _ in range(int(input())):
		n = int(input())
		culled = ceil(n / 4)
		print('9' * (n - culled) + '8' * culled)
prog()


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
for _ in range(r()):
	n = r()
	rem = n % 4
	small = n // 4
	big = n - small - (1 if rem != 0 else 0)
	firstAns = '9' * big
	midAns = ''
	if rem != 0:
		midAns = '8'
	lastAns = '8' * small
	print(firstAns + midAns + lastAns)


from math import *
t = int(input())
for i in range(t):
	n = int(input())
	r = ceil(n / 4)
	p = n - r
	s = '9' * p + '8' * r
	print(s)


for _ in range(int(input())):
	n = int(input())
	s = '8' * ((n + 3) // 4)
	k = '9' * (n - len(s))
	print(k + s)


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	k = n // 4
	if n % 4:
		print('9' * (n - k - 1) + '8' * (k + 1))
	else:
		print('9' * (n - k) + '8' * k)


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve(k):
	console('----- solving ------')
	if k == 1:
		return 8
	num_8 = (k - 1) // 4 + 1
	console(num_8)
	return '9' * (k - num_8) + '8' * num_8

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	k = int(input())
	res = solve(k)
	print(res)


for _ in range(int(input())):
	n = int(input())
	alln = 3 * n // 4
	s = ''
	g = alln
	for i in range(alln):
		s += '9'
	e = 3 * n % 4
	if e != 0:
		s += '8'
		g += 1
	for i in range(g, n):
		s += '8'
	print(s)


def answer(n):
	y = n // 4
	if n % 4 != 0:
		y += 1
	return int('9' * (n - y) + '8' * y)
t = int(input())
for i in range(t):
	n = int(input())
	print(answer(n))


length = int(input())
for x in range(length):
	n = int(input())
	k = n // 4 + 1
	if n % 4 == 0:
		k = k - 1
	for z in range(n - k):
		print(9, end='')
	for y in range(k):
		print(8, end='')
	print('')


for _ in range(int(input())):
	n = int(input())
	digit = (n + 3) // 4
	num = ['9'] * (n - digit) + ['8'] * digit
	print(''.join(num))


from sys import stdin
input = stdin.readline
import bisect
import math
for xoxo in range(1):
	for _ in range(int(input())):
		n = int(input())
		l = math.ceil(n / 4)
		ans = ''
		for i in range(n - l):
			print(9, end='')
		for i in range(l):
			print(8, end='')
		print()


import math
for t in range(int(input())):
	n = int(input())
	x = math.ceil(n / 4)
	st = '9' * (n - x) + '8' * x
	print(st)


from math import ceil

def func():
	n = int(input())
	mult = round(ceil(n / 4))
	print('9' * (n - mult) + '8' * mult)
t = int(input())
for i in range(t):
	func()


ls = []
t = int(input())
for z in range(t):
	temp = int(input())
	k = '1001' * temp
	k = k[:len(k) - temp]
	k += '0' * temp
	st = ''
	for i in range(0, temp * 4, +4):
		templs = k[i:i + 4]
		templs = '0b' + str(templs)
		templs = int(templs, 2)
		st = st + str(templs)
	i = len(st) - 1
	while st[i] == '0':
		st = st[:i] + '8' + st[i + 1:]
		i -= 1
	ls.append(st)
for i in ls:
	print(i)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	p = math.ceil(n / 4)
	val = 10 ** n - 1
	s = ''
	if p > 0:
		for i in range(p):
			s += '1'
	s = int(s)
	print(val - s)


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	eights = (n + 3) // 4
	for _ in range(n - eights):
		print('9', end='')
	for _ in range(eights):
		print('8', end='')
	print()


for t in range(int(input())):
	n = int(input())
	a = [9 for i in range(n)]
	rem = n % 4
	b = n // 4
	k = n - 1
	while b > 0:
		a[k] = 8
		k = k - 1
		b = b - 1
	if rem:
		a[k] = 8
	for i in range(n):
		print(a[i], end='')
	print()


for _ in range(int(input())):
	n = int(input())
	no_of_8 = 0
	if n / 4 > n // 4:
		no_of_8 = n // 4 + 1
	else:
		no_of_8 = n // 4
	str1 = '9' * (n - no_of_8) + '8' * no_of_8
	print(int(str1))


import math
for _ in range(int(input())):
	b = list(map(int, input().split()))
	if b[0] % 4 == 0:
		print('9' * (b[0] - b[0] // 4) + '8' * (b[0] // 4))
	else:
		print('9' * math.ceil(b[0] - b[0] // 4 - 1) + '8' * (b[0] // 4 + 1))


T = int(input())
for _ in range(0, T):
	n = int(input())
	tt = 3 * n // 4
	ans = '9' * tt
	ans += '8' * (n - len(ans))
	print(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import deque
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
t = ip()
for _ in range(t):
	n = ip()
	ch = ceil(n / 4)
	ans = '9' * (n - ch) + '8' * ch
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	k = n // 4
	l = n % 4
	if l != 0:
		k += 1
	s = ['9'] * (n - k) + ['8'] * k
	print(''.join(s))


def ceil(x, y):
	if x // y - x / y == 0:
		return x // y
	else:
		return x // y + 1
t = int(input())
for _ in range(t):
	n = int(input())
	x = ceil(n, 4)
	res = '9' * (n - x) + '8' * x
	print(res)


t = int(input())
lst1 = []
for i in range(t):
	output = ''
	n = int(input())
	output += '9' * (n - ((n - 1) // 4 + 1)) + '8' * ((n - 1) // 4 + 1)
	lst1.append(int(output))
for i in lst1:
	print(i)


t = int(input())
c = []
for j in range(t):
	n = int(input())
	s = ''
	if n <= 4:
		i = 1
		while i < n:
			s += str(9)
			i += 1
		s += str(8)
		c.append(s)
	else:
		if n % 4 == 0:
			k = n // 4
		else:
			k = n // 4
			k += 1
		i = 1
		while i <= n - k:
			s += str(9)
			i += 1
		i = 1
		while i <= k:
			s += str(8)
			i += 1
		c.append(s)
for k in c:
	print(k)


for tt in range(int(input())):
	n = int(input())
	itr = n // 4
	if itr == 0:
		ans = int('9' * n) - 1
	elif n % 4 == 0:
		ans = int('9' * (n - itr) + '8' * itr)
	else:
		ans = int('9' * (n - (itr + 1)) + '8' * (itr + 1))
	print(ans)


def inpint():
	return int(input())

def inpstr():
	return str(input())

def inparr():
	return list(map(int, input().strip().split()))

def inptup():
	return map(int, input().strip().split())
for _ in range(inpint()):
	n = inpint()
	c = (n - 1) // 4 + 1
	b = n - c
	a = '9' * b + '8' * c
	print(int(a))


import sys
input = iter(sys.stdin.read().splitlines()).__next__
TC = int(input())
for tc in range(TC):
	N = int(input())
	neights = (N - 1) // 4 + 1
	res = '9' * (N - neights) + '8' * neights
	print(res)


for q in range(int(input())):
	n = int(input())
	k = (n + 3) // 4
	print('9' * (n - k) + '8' * k)


import math
for o in range(int(input())):
	n = int(input())
	c = n // 4
	if n % 4 != 0:
		c = c + 1
	s = ''
	s = '9' * (n - c)
	s = s + '8' * c
	print(s)


import math
for _ in range(int(input())):
	n = int(input())
	x = math.ceil(n / 4)
	for i in range(n - x):
		print(9, end='')
	for j in range(x):
		print(8, end='')
	print()


import math

def main():
	n = int(input())
	for i in range(n):
		solve()

def solve():
	n = int(input())
	eights = math.ceil(n / 4)
	print((n - eights) * '9' + eights * '8')
main()


import math
t = int(input())
for i in range(t):
	n = int(input())
	p = int((n + 3) / 4)
	for j in range(n - p):
		print('9', end='')
	for j in range(p):
		print('8', end='')
	print()


import time, math as mt, bisect, sys
from sys import stdin, stdout
from collections import defaultdict
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return
mod = 10 ** 9 + 7

def solve():
	x = II()
	if x == 1:
		print(8)
	elif x % 4 == 0:
		v = x // 4
		print((x - v) * '9' + v * '8')
	else:
		v = x // 4 + 1
		print((x - v) * '9' + v * '8')
	return
t = II()
for i in range(t):
	solve()


import io, os
from collections import deque
import bisect
import math
RL = lambda : list(map(int, input().split(' ')))
T = int(input())
for _ in range(T):
	n = int(input())
	s = ''
	ceil = math.ceil(n / 4)
	s1 = '8' * ceil
	s2 = '9' * (n - ceil)
	s = s2 + s1
	print(s)


import sys
import math

def solve(n):
	answer = [9 for _ in range(n)]
	num_to_8 = math.ceil(n / 4)
	i = n - 1
	while num_to_8 > 0:
		answer[i] -= 1
		num_to_8 -= 1
		i -= 1
	return int(''.join((str(d) for d in answer)))

def main(cases):
	for case in cases:
		print(solve(case))
cases = []
for (e, line) in enumerate(sys.stdin.readlines()):
	if e == 0:
		continue
	cases.append(int(line.strip()))
main(cases)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	N = int(input())
	x = -(-N // 4)
	print(''.join(['9'] * (N - x) + ['8'] * x))


from sys import stdin
from math import ceil

def main():
	input = stdin.readline
	for t in range(int(input())):
		n = int(input())
		s = int('9' * (n - ceil(n / 4)) + '8' * ceil(n / 4))
		print(s)
main()


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print('8')
	else:
		s = '1001' * n
		l = 0
		for i in range(1, n + 1):
			if i % 4 != 0:
				if s[-i] == '1':
					l += 1
		new = '9' * (n - l) + '8' * l
		print(new)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	temp2 = math.ceil(n / 4)
	temp1 = n - temp2
	for i in range(temp1):
		print(9, end='')
	for i in range(temp2):
		print(8, end='')
	print()


def get_answer(n):
	x = list('9' * n)
	k_digits_can_replace_n = n
	x_digits_can_replace_n = (k_digits_can_replace_n + 3) // 4
	assert x_digits_can_replace_n != 0
	x[-x_digits_can_replace_n:] = list('8' * x_digits_can_replace_n)
	return ''.join(x)

def main():
	t = int(input())
	ns = (int(input()) for _ in range(t))
	answers = map(get_answer, ns)
	for answer in answers:
		print(answer)
main()


t = int(input())
for i in range(t):
	n = int(input())
	m = n // 4
	if n % 4 != 0:
		m += 1
	for j in range(n - m):
		print('9', end='')
	for j in range(m):
		print('8', end='')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	m = (n - 1) // 4 + 1
	x = ''
	for i in range(n - m):
		x += '9'
	for i in range(m):
		x += '8'
	print(x)


gi = lambda : list(map(int, input().split()))
for _ in range(gi()[0]):
	(n,) = gi()
	d = n // 4
	if n % 4:
		d += 1
	print('9' * (n - d) + '8' * d)


from math import *
import sys
input = sys.stdin.readline
a = int(input())
for x in range(a):
	b = int(input())
	if b == 1:
		print(8)
	else:
		n = ceil(b / 4)
		t = (b - n) * '9' + n * '8'
		print(t)


for _ in range(int(input())):
	t = int(input())
	a = (t - 1) // 4
	a = a + 1
	ans = '9' * (t - a) + '8' * a
	print(ans)


t = int(input())
while t:
	n = int(input())
	x = n // 4
	count = x
	s = '8' * x
	if n % 4 != 0:
		s = s + '8'
		count = count + 1
	v = '9' * (n - count)
	final = v + s
	print(final)
	t = t - 1


T = int(input())
for t in range(T):
	n = int(input())
	s = ''
	l = int(n / 4)
	if n % 4 == 0:
		for i in range(n - l):
			s += '9'
		for j in range(l):
			s += '8'
		print(s)
	else:
		for i in range(n - l - 1):
			s += '9'
		for j in range(l + 1):
			s += '8'
		print(s)


t = int(input())
for i in range(t):
	n = int(input())
	eit = n // 4
	p = n % 4
	if p != 0:
		eit += 1
	l = ['9'] * (n - eit)
	for k in range(eit):
		l.append('8')
	print(''.join(l))


n = {}
t = int(input())
for a in range(t):
	n = int(input())
	npureeights = n // 4
	nmaybeeights = n % 4
	if nmaybeeights != 0:
		npureeights += 1
	rp = '9' * (n - npureeights) + '8' * npureeights
	print(rp)


import math
t = int(input())
while t:
	t -= 1
	n = int(input())
	ans = pow(10, n) - 1
	minus = '1' * math.ceil(n / 4)
	ans -= int(minus)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	s = '1001' * n
	s = list(s)
	cnt = n // 4
	if n % 4:
		cnt += 1
	print('9' * (n - cnt) + '8' * cnt)


def solve():
	n = int(input())
	if n == 1:
		print(8)
		return
	else:
		ans = ''
		k = n // 4 + min(n % 4, 1)
		for i in range(n - k):
			ans += '9'
		for i in range(k):
			ans += '8'
		print(ans)
		return
t = int(input())
for i in range(t):
	solve()


T = int(input())
for i in range(T):
	N = int(input())
	ans = '9'
	p = N // 4
	temp = N - p - 1
	if N % 4 == 0:
		p -= 1
	ans *= temp
	x = '8'
	x *= p
	if N % 4 == 0:
		print('9' + ans + x + '8')
	else:
		print(ans + x + '8')


import math
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	temp = math.ceil(n / 4)
	temp2 = n - temp
	print('9' * temp2, end='')
	print('8' * temp)


from sys import stdin
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
(t,) = gil()
for _ in range(t):
	(n,) = gil()
	a = ['9'] * n
	r = 4
	for i in reversed(range(n)):
		if n >= r:
			a[i] = '8'
		elif r - 4 < n:
			a[i] = '8'
		else:
			break
		r += 4
	print(''.join(a))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	x = math.ceil(n / 4)
	y = n - x
	a = '9'
	b = '8'
	str = a * y + b * x
	print(str)


tc = int(input())
for ctr in range(tc):
	n = int(input())
	x = (n + 3) // 4
	for i in range(n - x):
		print(9, end='')
	for i in range(x):
		print(8, end='')
	print()


import sys
input = sys.stdin.readline
test = int(input())
nlist = [0]
cont = 1
for i in range(1, 10 ** 5 + 10):
	nlist.append(cont)
	if i % 4 == 0:
		cont += 1
for _ in range(test):
	N = int(input())
	number8 = nlist[N]
	number9 = N - number8
	print('9' * number9 + '8' * number8)


n = int(input())
for i in range(n):
	t = int(input())
	r = 3 * t // 4
	string = ''
	for j in range(r):
		string += '9'
	for j in range(t - r):
		string += '8'
	string += '\n'
	print(string, end='')


import sys, math, bisect
from collections import Counter, defaultdict as dd

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
for _ in range(int(data())):
	n = int(input())
	b = math.ceil(n / 4)
	a = '9' * (n - b) + '8' * b
	print(a)


def multiply(s, num):
	if num == 1:
		return s
	if num == 0:
		return ''
	a = multiply(s, int(num / 2))
	a = a + a
	if num % 2 == 1:
		a = a + s
	return a
t = input()
t = int(t)
for i in range(t):
	ans = ''
	n = input()
	n = int(n)
	yet = multiply('8', int(n / 4))
	if n % 4 != 0:
		yet += '8'
	count = len(yet)
	ans = multiply('9', int(n - count)) + yet
	print(ans)


t = int(input())
for xx in range(0, t):
	n = int(input())
	m = n // 4
	a = []
	if n % 4 != 0:
		for i in range(0, n - 1 - m):
			a.append(9)
		for i in range(0, m + 1):
			a.append(8)
	else:
		for i in range(0, n - m):
			a.append(9)
		for i in range(0, m):
			a.append(8)
	for i in range(0, len(a)):
		print(a[i], end='')
	print()


import sys, math, cmath, time
start_time = time.time()

def solve():
	n = inp()
	print('9' * (n - math.ceil(n / 4)) + '8' * math.ceil(n / 4))

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = (q[ord(a[i]) - 97], 1)
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = []
for _ in range(T):
	N = int(readline())
	ei = -(-N // 4)
	ni = N - ei
	Ans.append(''.join(map(str, [9] * ni + [8] * ei)))
print('\n'.join(Ans))


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k)))) % NUMBER
from collections import deque, defaultdict
import heapq
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def dfs(g, timeIn, timeOut, depths, parents):
	cnt = 0
	stack = [[1, 0, 0, 0]]
	while stack:
		(v, neig_i, parent, depth) = stack[-1]
		parents[v] = parent
		depths[v] = depth
		if neig_i == 0:
			timeIn[v] = cnt
			cnt += 1
		while neig_i < len(g[v]):
			u = g[v][neig_i]
			if u == parent:
				neig_i += 1
				continue
			stack[-1][1] = neig_i + 1
			stack.append([u, 0, v, depth + 1])
			break
		if neig_i == len(g[v]):
			stack.pop()
			timeOut[v] = cnt
			cnt += 1
cnt = 0

@bootstrap
def dfs(v, adj, timeIn, timeOut, depths, parents, parent=0, depth=0):
	global cnt
	parents[v] = parent
	depths[v] = depth
	timeIn[v] = cnt
	cnt += 1
	for u in adj[v]:
		if u == parent:
			continue
		yield dfs(u, adj, timeIn, timeOut, depths, parents, v, depth + 1)
	timeOut[v] = cnt
	cnt += 1
	yield

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def get_num_2_5(n):
	twos = 0
	fives = 0
	while n > 0 and n % 2 == 0:
		n //= 2
		twos += 1
	while n > 0 and n % 5 == 0:
		n //= 5
		fives += 1
	return (twos, fives)

def shift(a, i, num):
	for _ in range(num):
		(a[i], a[i + 1], a[i + 2]) = (a[i + 2], a[i], a[i + 1])

def equal(x, y):
	return abs(x - y) <= 1e-09

def getAngle(a, b, c):
	ang = math.degrees(math.atan2(c[1] - b[1], c[0] - b[0]) - math.atan2(a[1] - b[1], a[0] - b[0]))
	return ang + 360 if ang < 0 else ang

def getLength(a, b):
	return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
from heapq import heapify, heappush, heappop

def bfs(adj):
	s = set()
	d = defaultdict(set)
	q = deque([])
	s.add(0)
	d[0].add(0)
	q.append((0, 0))
	while len(q) > 0:
		(v, depth) = q.popleft()
		for u in adj[v]:
			if u not in s:
				s.add(u)
				d[depth + 1].add(u)
				q.append((u, depth + 1))
	return d

def isSubsetSum(arr, n, summ):
	subarr = [[False for i in range(summ + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subarr[i][0] = True
	for i in range(1, summ + 1):
		subarr[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, summ + 1):
			if j < arr[i - 1]:
				subarr[i][j] = subarr[i - 1][j]
			if j >= arr[i - 1]:
				subarr[i][j] = subarr[i - 1][j] or subarr[i - 1][j - arr[i - 1]]
	return subarr[n][summ]

def bfs(v, adj, onpath):
	s = set()
	d = defaultdict(set)
	q = deque([])
	s.add(0)
	d[0].add(0)
	q.append((0, 0))
	while len(q) > 0:
		(v, depth) = q.popleft()
		for u in adj[v]:
			if u not in s:
				s.add(u)
				d[depth + 1].add(u)
				q.append((u, depth + 1))
	return d

@bootstrap
def dfs(v, adj, vis, dp):
	dp[v][0] = 0
	dp[v][1] = 1
	for u in adj[v]:
		if vis[u]:
			continue
		vis[u] = True
		yield dfs(u, adj, vis, dp)
		dp[v][0] += max(dp[u][1], dp[u][0])
		dp[v][1] += dp[u][0]
	yield

def solution(n):
	num = (n + 3) // 4
	return '9' * (n - num) + '8' * num

def main():
	T = 1
	T = ri()
	for i in range(T):
		n = ri()
		x = solution(n)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


for t in range(int(input())):
	n = int(input())
	ind = 0
	if n % 4 == 0:
		ind = int(n / 4)
	else:
		ind = int(n / 4 + 1)
	ans = '9' * (n - ind) + '8' * ind
	print(ans)


for n in [*open(0)][1:]:
	n = int(n)
	k1 = 4 - n % 4 - 1
	k2 = n // 4
	print(''.join(['9' for i in range(n - k2 - 1)]) + ('8', '8', '8', '9')[k1] + ''.join(['8' for i in range(k2)]))


for testcase in range(int(input())):
	n = int(input())
	n8 = (n + 3) // 4
	print('9' * (n - n8) + '8' * n8)


for _ in range(int(input())):
	n = int(input())
	x = int(3 * n % 4)
	y = int(3 * n / 4)
	z = int(n / 4)
	ans = '9' * y
	if x != 0:
		ans += '8'
	ans += '8' * z
	print(ans)


for _ in range(int(input())):
	n = int(input())
	res = ''
	d = n // 4
	if n % 4 == 0:
		d -= 1
	d += 1
	f = n - d
	res += '9' * f
	res += '8' * d
	print(res)


from sys import stdin, stdout

def input():
	return stdin.readline().strip()

def chunks(lst, n):
	for i in range(0, len(lst), n):
		yield lst[i:i + n]

def r_of(x):
	k = ['{0:b}'.format(int(c)) for c in str(x)]
	k = ''.join(k)
	r = k[0:len(k) - len(str(x))]
	if len(r) == 0:
		return 0
	return int(r, 2)

def ans_slow(n):
	n -= 1
	max_r = max((r_of(x) for x in range(10 ** n, 10 ** (n + 1) - 1)))
	min_x = min((x for x in range(10 ** n, 10 ** (n + 1) - 1) if r_of(x) == max_r))
	return min_x

def ans(n):
	s = [1, 0, 0, 1] * n
	for i in range(n):
		s[i] = 0
	s = s[::-1]
	s = list(chunks(s, 4))
	ret = []
	for c in s:
		if c[0] == 0:
			c = [1, 0, 0, 0]
		ss = ''.join(map(str, c))
		ret += [int(ss, 2)]
	return ''.join(map(str, ret))
T = int(input())
for _ in range(T):
	n = int(input())
	print(ans(n))


t = int(input())
for T in range(t):
	n = int(input())
	nine = n - (n + 3) // 4
	print('9' * nine + '8' * (n - nine))


from sys import stdin
input = stdin.readline
import bisect
import math
out = []
for xoxo in range(1):
	for _ in range(int(input())):
		n = int(input())
		l = math.ceil(n / 4)
		ans = ''
		out.append('9' * (n - l) + '8' * l)
print('\n'.join(out))


import sys
input = lambda : sys.stdin.readline().strip()
char = [chr(i) for i in range(97, 123)]
CHAR = [chr(i) for i in range(65, 91)]
mp = lambda : list(map(int, input().split()))
INT = lambda : int(input())
rn = lambda : range(INT())
from math import ceil, sqrt, factorial, gcd
for _ in rn():
	n = INT()
	k = ceil(n / 4)
	print('9' * (n - k) + '8' * k)


t = int(input())
for _ in range(t):
	n = int(input())
	(lap, rem) = divmod(n, 4)
	cnt8 = lap + (rem >= 1)
	print('9' * (n - cnt8) + '8' * cnt8)


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	ei = math.ceil(n / 4)
	ans = '9' * (n - ei)
	ans += '8' * ei
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	k = n / 4
	l = int(k)
	if k == l:
		for i in range(n - l):
			print('9', end='')
		for i in range(l):
			print('8', end='')
		print('')
	else:
		l += 1
		for i in range(n - l):
			print('9', end='')
		for i in range(l):
			print('8', end='')
		print('')
	t -= 1


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi
import heapq, random

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_le(a, x):
	i = bi.bisect_right(a, x)
	if i:
		return i - 1
	else:
		return -1

def main():
	try:
		n = I()
		t = math.ceil(n / 4)
		ans = '9' * (n - t) + '8' * t
		print(ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


from math import ceil as c
for _ in range(int(input())):
	n = int(input())
	e = c(n / 4)
	o = n - e
	print('9' * o + '8' * e)


import sys
import math
for _ in range(int(input())):
	N = int(input())
	if N == 1:
		print('8')
	else:
		z = N // 4
		if N % 4 != 0:
			z += 1
		s = '9' * (N - z) + '8' * z
		print(s)


import math
tests = int(input())
for t in range(tests):
	n = int(input())
	d = math.ceil(n / 4)
	print('9' * (n - d) + '8' * d)


from sys import stdin

def r():
	return stdin.readline().strip()

def r_t(tp):
	return map(tp, r().strip().split())

def r_a(tp):
	return list(r_t(tp))

def solve(n):
	ans = '9' * (n * 3 // 4)
	if n % 4 != 0:
		ans += '8'
	ans += '8' * (n // 4)
	return ans

def main():
	c = int(r())
	for _ in range(c):
		n = int(r())
		print(solve(n))
main()


from collections import defaultdict

def ii():
	return int(input())

def si():
	return input()

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def rfinder(x):
	temp = str(x)
	b = ''
	for i in range(len(temp)):
		tb = bin(int(temp[i]))
		b += tb[2:]
	if len(b) - len(temp) <= 0:
		return 0
	else:
		r = b[0:len(b) - len(temp)]
		r = int(r, 2)
		return r
t = ii()
for _ in range(t):
	n = ii()
	if n % 4 == 0:
		a = n // 4
	else:
		a = n // 4 + 1
	print(int('9' * (n - a) + '8' * a))


def main():
	for t in range(int(input())):
		n = int(input())
		a = n * 4
		b = n // 4
		c = n % 4
		if c == 0:
			for i in range(n - b):
				print('9', end='')
			for i in range(b):
				print('8', end='')
		else:
			for i in range(n - b - 1):
				print('9', end='')
			print('8', end='')
			for i in range(b):
				print('8', end='')
		print()
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for j in range(t):
	n = int(input())
	if n % 4 != 0:
		m = n // 4 + 1
	else:
		m = n // 4
	n = n - m
	a = ''
	for j in range(n):
		a += '9'
	for j in range(m):
		a += '8'
	print(a)


for s in range(int(input())):
	n = int(input())
	rama = []
	d = n // 4
	if n % 4 != 0:
		d += 1
	for i in range(n - d):
		rama.append(9)
	for i in range(d):
		rama.append(8)
	for i in rama:
		print(i, end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	n2 = n - 1
	quo = n2 // 4
	rem_digits = n - quo
	quo += 1
	rem_digits -= 1
	res = '9' * rem_digits
	res += '8' * quo
	print(res)


import sys
import math
inputlines = sys.stdin.readlines()
number_of_testcases = int(inputlines[0])
for i in range(number_of_testcases):
	number = int(inputlines[i + 1])
	number_of_eight = math.ceil(number / 4)
	number_of_nines = number - number_of_eight
	for i in range(number_of_nines):
		print('9', end='')
	for i in range(number_of_eight):
		print('8', end='')
	print('')


from math import ceil
for _ in range(int(input())):
	n = int(input())
	eight = ceil(n / 4)
	print('9' * (n - eight), '8' * eight, sep='')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	z = math.ceil(n / 4)
	while n - z > 0:
		print('9', end='')
		n -= 1
	while z > 0:
		print('8', end='')
		z -= 1
	print()


a = int(input())
for i in range(0, a):
	b = int(input())
	c = ''
	if b % 4 == 0:
		d = b // 4
	else:
		d = b // 4 + 1
	c += '9' * (b - d)
	c += '8' * d
	print(c)


from sys import stdout
from math import ceil
for _ in range(int(input())):
	n = int(input())
	temp = ceil(n / 4)
	temp2 = n - temp
	ans = '9' * temp2
	ans += '8' * temp
	stdout.write(ans)
	print()


import math
t = int(input())
while t > 0:
	n = int(input())
	if n % 4 == 0:
		l = int(n // 4)
		print('9' * (n - l), '8' * l, sep='')
	else:
		l = int(n // 4)
		print('9' * (n - l - 1), '8' * (l + 1), sep='')
	t -= 1


for t in range(int(input())):
	n = int(input())
	a = n
	n = n - 1
	count = n // 4
	st = ''
	st = '9' * (a - count - 1) + '8' * (count + 1)
	print(st)


a = input()
for x in range(int(a)):
	c = int(input())
	if c % 4 == 0:
		tag = max(c // 4, 1)
	else:
		tag = max(c // 4 + 1, 1)
	print(int('9' * (c - tag) + '8' * tag))


from sys import stdin, stdout
q = int(input())
for i in range(q):
	n = int(input())
	if n % 4 == 0:
		d = n // 4
		s = '9' * (n - d)
		s += '8' * d
		print(s)
	else:
		d = n // 4
		d += 1
		s = '9' * (n - d)
		s += '8' * d
		print(s)


for _ in range(int(input())):
	n = int(input())
	eights = (n - 1) // 4 + 1
	nines = n - eights
	print('9' * nines + '8' * eights)


import sys, math

def input():
	return sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	n = int(input())
	s = ''
	k = math.ceil(n / 4)
	for i in range(n - k):
		s += '9'
	for i in range(n - k, n):
		s += '8'
	print(s)


for t in range(int(input())):
	n = int(input())
	a = 4 * n
	b = n // 4
	c = n % 4
	ans = 0
	if c == 0:
		ans = int('9' * (n - b) + '8' * b)
	else:
		ans = int('9' * (n - b - 1) + '8' * (b + 1))
	print(ans)


T = int(input())
for case in range(T):
	n = int(input())
	r = (n - 1) % 4
	d = (n - 1 - r) // 4
	s = '9' * (n - d - 1) + '8' * (d + 1)
	print(s)


rw = int(input())
for qwe in range(rw):
	n = int(input())
	f = (n + 3) // 4
	print('9' * (n - f) + '8' * f)


def ques1(n):
	s = ''
	p = n // 4
	if n % 4 != 0:
		p += 1
	n -= p
	s = '9' * n + p * '8'
	print(int(s))
t = int(input())
for i in range(t):
	n = int(input())
	ans = ques1(n)
	ans


import math
T = int(input())
for t in range(T):
	n = int(input())
	eights = math.ceil(n / 4)
	ans = '9' * (n - eights) + '8' * eights
	print(ans)


def ceildiv(a, b):
	if a % b != 0:
		return a // b + 1
	else:
		return a // b

def solve():
	n = int(input())
	arr = [9] * n
	j = -1
	for i in range(ceildiv(n, 4)):
		arr[j] = 8
		j -= 1
	print(''.join((str(v) for v in arr)))
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for t in range(t):
	n = int(input())
	v = n // 4
	s1 = '8' * (v + int(n % 4 != 0))
	v += int(n % 4 != 0)
	s2 = ''
	if v < n:
		s2 = '9' * (n - v)
	print(s2 + s1)


t = int(input())
for i in range(t):
	n = int(input())
	if 0 < n % 4 <= 3:
		s = ''
		s += (n // 4 + 1) * '8'
	else:
		s = ''
		s += n // 4 * '8'
	s1 = '9' * (n - len(s))
	print(s1 + s)


t = int(input())
for _ in range(t):
	n = int(input())
	eights = -(-n // 4)
	nines = n - eights
	for i in range(nines):
		print(9, end='')
	for i in range(eights):
		print(8, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	ans = ''
	n1 = n
	while n > 0:
		ans += '8'
		n -= 4
	a = len(ans)
	ans += '9' * (n1 - a)
	print(ans[::-1])


import sys
input = sys.stdin.readline
t = int(input())
Et = [0]
no = 1
for i in range(1, 10 ** 5 + 10):
	Et.append(no)
	if i % 4 == 0:
		no += 1
for _ in range(t):
	n = int(input())
	ETT = Et[n]
	ENN = n - ETT
	print('9' * ENN + '8' * ETT)


for i in range(int(input())):
	n = int(input())
	quot = n // 4
	rem = n % 4
	left = '9' * (n - quot - 1)
	right = '8' * quot
	if rem != 0:
		res = left + '8' + right
	else:
		res = left + '9' + right
	print(res)


res = [0]
count = 1
for x in range(1, 10 ** 5 + 10):
	res.append(count)
	if x % 4 == 0:
		count += 1
for _ in range(int(input())):
	z = int(input())
	tmp = res[z]
	sol = z - tmp
	print('9' * sol + '8' * tmp)


import math

def mi():
	return map(int, input().split())

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def si():
	return input().split()
t = ii()
for _ in range(t):
	n = ii()
	total = n // 4
	if n % 4:
		total += 1
	print('9' * (n - total) + '8' * total)


t = int(input())
for i in range(t):
	k = int(input())
	furthest_removal_digit_bit_index = k % 4
	removal_digit_index = (k - 1) // 4
	L = [9 for _ in range(k)]
	L[removal_digit_index] = 8
	for j in range(removal_digit_index):
		L[j] = 8
	L = list(map(str, L))
	L.reverse()
	print(''.join(L))


t = int(input())
while t:
	n = int(input())
	ans = ''
	p = n // 4
	for i in range(n - p - 1):
		ans += '9'
	if n % 4 == 0:
		ans += '9'
	else:
		ans += '8'
	for i in range(p):
		ans += '8'
	print(ans)
	t -= 1


from math import *
t = int(input())
for _ in range(t):
	n = int(input())
	k = (n - 1) // 4
	k = k + 1
	for i in range(n - k):
		print('9', end='')
	for i in range(k):
		print('8', end='')
	print()


for i in range(int(input())):
	t = int(input())
	num_eights = (t - 1) // 4 + 1
	num_nines = t - num_eights
	print('9' * num_nines + '8' * num_eights)


import math
for _ in range(int(input())):
	n = int(input())
	s = '1001' * n
	l = len(s)
	x = s[l - n:]
	rem = math.ceil(len(x) / 4)
	print('9' * (n - rem) + '8' * rem)


t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	m = (n + 3) // 4
	ans.append('9' * (n - m))
	ans.append('8' * m)
	print(''.join(map(str, ans)))


import math
t = int(input())
while t:
	m = int(input())
	q = math.ceil(m / 4)
	print('9' * (m - q) + '8' * q)
	t -= 1


import math
for _ in range(int(input())):
	x = int(input())
	l = []
	n = math.ceil(x / 4)
	for i in range(n):
		l.append('8')
	for i in range(x - n):
		l.append('9')
	l.reverse()
	print(''.join(l))


import string
import random
t = input()
t = int(t)
while t > 0:
	n = int(input())
	digit = n * 3
	n_9 = int(digit / 4)
	n_8 = n - n_9
	ans = ''
	while n_9 != 0:
		ans = ans + '9'
		n_9 -= 1
	while n_8 != 0:
		ans = ans + '8'
		n_8 -= 1
	print(int(ans))
	t -= 1


for test in range(int(input())):
	n = int(input())
	a = n // 4
	if n % 4 > 0:
		a += 1
	t = '9' * (n - a)
	t = t + '8' * a
	print(t)


import sys
import math
t = int(sys.stdin.readline())
for i in range(t):
	n = int(sys.stdin.readline())
	val = math.ceil(n / 4)
	print('9' * (n - val) + '8' * val)


import math
t = int(input())
for tt in range(t):
	n = int(input())
	xxxx = '8' * int(math.ceil(n / 4))
	yyyy = '9' * (n - int(math.ceil(n / 4)))
	print(yyyy + xxxx)


import sys
t = int(sys.stdin.readline().strip())
inp = []
for i in range(t):
	n = int(sys.stdin.readline().strip())
	eights = (n + 3) // 4
	result = ['9' * (n - eights), '8' * eights]
	print(''.join(result))


for _ in range(int(input())):
	n = int(input())
	temp = n
	ans = ''
	cnt = 0
	ans1 = '8' * (n // 4)
	cnt += n // 4
	if n % 4 != 0:
		ans1 += '8'
		cnt += 1
	ans = '9' * (n - cnt)
	print(ans + ans1)


import sys, math
from collections import Counter, deque, defaultdict
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input()
C = lambda : input().strip().split()
mod = 1000000007

def pl(a):
	print(' '.join(list(map(str, a))))

def solve():
	n = I()
	print('9' * (n - (n + 3) // 4) + '8' * ((n + 3) // 4))
for _ in range(I()):
	solve()


from math import ceil
for _ in range(int(input())):
	n = int(input())
	fin = ''
	eights = ceil(n / 4)
	print('9' * (n - eights) + '8' * eights)


t = int(input())
for i in range(t):
	n = int(input())
	t8 = 0
	if n % 4 == 0:
		t8 = n // 4
		t9 = n - t8
		ans = ''
		for j in range(t9):
			ans += '9'
		for j in range(t8):
			ans += '8'
		print(ans)
		continue
	else:
		t8 = n // 4 + 1
		t9 = n - t8
		ans = ''
		for j in range(t9):
			ans += '9'
		for j in range(t8):
			ans += '8'
		print(ans)
		continue


T = int(input())
for i in range(T):
	n = int(input())
	if n == 1:
		print(8)
	else:
		a = (n - 1) // 4 + 1
		print((n - a) * '9' + a * '8')


t = int(input())
for _ in range(t):
	n = int(input())
	st = '1001' * n
	s = st[:3 * n] + '0' * (n % 4) + '1000' * (n // 4)
	for i in range(0, len(s) - 3, 4):
		print(int(s[i:i + 4], 2), end='')
	print()


import math
t = int(input())
for x in range(t):
	n = int(input())
	t = math.ceil(n / 4)
	r = n - t
	d = '9' * r + '8' * t
	print(d)


from math import *
from math import factorial as fact, comb as ncr
from bisect import bisect_left as bl
from bisect import bisect_right as br
from array import array
from collections import Counter as ctr
from collections import deque as dq
li = lambda : list(map(int, input().split()))
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')

def solve():
	for _ in range(int(input())):
		n = int(input())
		n8 = ceil(n / 4)
		print('9' * (n - n8) + '8' * n8)
solve()


for __ in range(int(input())):
	n = int(input())
	ans = []
	for i in range(n - (n + 3) // 4):
		ans.append(9)
	for i in range((n + 3) // 4):
		ans.append(8)
	print(''.join(map(str, ans)))


for _ in range(int(input())):
	n = int(input())
	partial = (n - 1) // 4 + 1
	print('9' * (n - partial), '8' * partial, sep='')


t = int(input())
for _ in range(t):
	n = int(input())
	p = n // 4
	rem = n % 4
	if rem == 0:
		print('9' * (n - p) + '8' * p)
	else:
		print('9' * (n - p - 1) + '8' * (p + 1))


import math
for _ in [0] * int(input()):
	n = int(input())
	times = int(math.ceil(n / 4))
	print((n - times) * '9' + times * '8')


t = int(input())
while t:
	n = int(input())
	if n % 4 == 0:
		ans1 = n // 4
	else:
		ans1 = n // 4 + 1
	ans2 = n - ans1
	s = ''
	for i in range(ans2):
		s += '9'
	for i in range(ans1):
		s += '8'
	print(s)
	t = t - 1


for _ in range(int(input())):
	a = int(input())
	x = (a + 3) // 4
	for i in range(0, a - x, 1):
		print(9, end='')
	for i in range(0, x, 1):
		print(8, end='')
	print()


t = int(input())
while t:
	t += -1
	n = int(input())
	tmp = (n * 4 - n) // 4
	print('9' * tmp + '8' * (n - tmp))


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	n = I()
	p = n * 4 - n
	p = p // 4
	ans = []
	for i in range(p):
		ans.append(9)
	for i in range(n - p):
		ans.append(8)
	print(''.join(map(str, ans)))
for _ in range(I()):
	solve()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	if n == 1:
		print(8)
		continue
	ans = [9] * n
	cur = n - 1
	while n >= 4:
		ans[cur] = 8
		cur -= 1
		n -= 4
	if n == 1:
		ans[cur] = 8
	elif n == 2:
		ans[cur] = 8
	elif n == 3:
		ans[cur] = 8
	print(''.join((str(k) for k in ans)))


import math
for z in range(int(input())):
	n = int(input())
	d = math.ceil(n / 4)
	print(int((n - d) * '9' + d * '8'))


from collections import Counter
from collections import OrderedDict

def SOCountR(mylist):
	return OrderedDict(sorted(Counter(mylist).items(), reverse=True))

def SOCount(mylist):
	return OrderedDict(sorted(Counter(mylist).items()))

def freq_count(mylist):
	return Counter(mylist)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	temp = n // 4
	if n % 4 != 0:
		temp += 1
	for i in range(n - temp):
		print('9', end='')
	for i in range(temp):
		print('8', end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	x = (n + 3) // 4
	res = []
	for _ in range(n - x):
		res.append('9')
	for _ in range(x):
		res.append('8')
	print(''.join(res))


import math
TestCases = int(input())
values = []
for x in range(TestCases):
	values.append(int(input()))
for x in values:
	if x >= 4:
		y = math.ceil(x / 4)
		result = 10 ** x - 1 - int(y * '1')
		print(result)
	else:
		result = 10 ** x - 2
		print(result)


def str2bcd(s):
	bcd_list = []
	ans = []
	for i in range(0, len(s), 4):
		bcd_list.append(s[i:i + 4])
	for e in bcd_list:
		ans.append(int(e, 2))
	return ''.join(map(str, ans))

def answer(n):
	bstr = n * '1001'
	bstr = list(bstr)
	for i in range(-1, -(n + 1), -1):
		bstr[i] = '0'
	bstr = ''.join(bstr)
	bstr = str2bcd(bstr)
	return bstr

def answer2(n):
	num_eights = (n - 1) // 4 + 1
	num_nines = n - num_eights
	return num_nines * '9' + num_eights * '8'

def main():
	t = int(input())
	n = [0] * t
	for j in range(t):
		n[j] = int(input())
	for j in range(t):
		print(answer2(n[j]))
main()


import sys
INP = lambda : sys.stdin.readline().strip()
INT = lambda : int(INP())
MAP = lambda : map(int, INP().split())
ARR = lambda : [int(i) for i in INP().split()]

def JOIN(arr, x=' '):
	return x.join([str(i) for i in arr])

def EXIT(x='NO'):
	print(x)
	exit()

def solve():
	n = INT()
	m = n * 3 // 4
	ans = '9' * m + '8' * (n - m)
	print(ans)
for _ in range(INT()):
	solve()


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	n = int(I1())
	x = math.ceil(n / 4)
	s = (n - x) * '9' + x * '8'
	print(s)


import math
x = int(input())
for i in range(x):
	y = int(input())
	a = math.ceil(y / 4)
	print('9' * (y - a) + '8' * a)


import sys

def main():
	t = int(input())
	while t:
		n = int(input())
		ans = 0
		if n % 4 != 0:
			ans = n // 4 + 1
		else:
			ans = n // 4
		s = ans * '8'
		s1 = (n - ans) * '9'
		s1 += s
		print(s1)
		t -= 1
main()


from sys import stdin, stdout
import math
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	x = (n - 1) // 4 + 1
	print('9' * (n - x) + '8' * x)


import math
for t in range(int(input())):
	n = int(input())
	no_of_eight = math.ceil(n / 4)
	ans = '9' * (n - no_of_eight) + '8' * no_of_eight
	print(ans)


import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
input = sys.stdin.readline
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for _ in range(inin()):
	n = inin()
	r = (n + 3) // 4
	print('9' * (n - r) + '8' * r)


for _ in range(int(input())):
	n = int(input())
	s = ''
	s1 = ''
	s2 = ''
	s1 += '8' * ((n - 1) // 4 + 1)
	ls2 = n - len(s1)
	s2 += '9' * ls2
	s += s2 + s1
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	s = ''
	if n == 1:
		s = '8'
	elif n <= 4:
		for i in range(n - 1):
			s += '9'
		s += '8'
	elif n % 4 != 0:
		t = n // 4 + 1
		l = n - t
		for i in range(l):
			s += '9'
		for i in range(t):
			s += '8'
	else:
		t = n // 4
		l = n - t
		for i in range(l):
			s += '9'
		for i in range(t):
			s += '8'
	print(s)


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print('8')
	elif n == 2:
		print('98')
	else:
		m = ['9'] * n
		n = (n + 3) // 4
		for i in range(n):
			m[-1 - i] = '8'
		print(''.join(m))


test_cases = int(input())
for test_case in range(test_cases):
	n = int(input())
	dict = {0: 0, 1: 1, 2: 10, 3: 11, 4: 100, 5: 101, 6: 110, 7: 111, 8: 1000, 9: 1001}
	rem = n % 4
	q = n // 4
	if rem > 0:
		q += 1
	x = '9' * (n - q)
	x += '8' * q
	print(x)


from math import ceil
from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	last = ceil(n / 4)
	res = '9' * (n - last) + '8' * last
	print(res)
	t -= 1


import math

def main():
	n = int(input())
	eight = math.ceil(n / 4)
	nine = n - eight
	line = '9' * nine + '8' * eight
	print(line)
t = int(input())
for i in range(t):
	main()


for _ in range(int(input())):
	n = int(input())
	temp = n // 4 + 1
	if n % 4 == 0:
		temp -= 1
	rem = n - temp
	for i in range(rem):
		print(9, end='')
	for i in range(temp):
		print(8, end='')
	print()


cases = int(input())
for case in range(cases):
	n = int(input())
	print((n - (n + 3) // 4) * '9' + (n + 3) // 4 * '8')


for nt in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
		continue
	m = (n - 1) // 4 + 1
	ans = ['9'] * n
	for i in range(n - 1, n - m - 1, -1):
		ans[i] = '8'
	print(''.join(map(str, ans)))


import math
t = int(input())
for tt in range(t):
	n = int(input())
	num8 = math.ceil(n / 4)
	print('9' * (n - num8) + '8' * num8)


from math import ceil
for _ in range(int(input())):
	n = int(input())
	e = ceil(n / 4)
	for i in range(n):
		if i < n - e:
			print(9, end='')
		else:
			print(8, end='')
	print()


t = int(input())
for h in range(t):
	n = int(input())
	if n % 4 == 0:
		print('{}'.format(10 ** n - int((n // 4 - 1) * '1' + '2')))
	else:
		print('{}'.format(10 ** n - int(n // 4 * '1' + '2')))


for _ in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		res = '8' * (n // 4)
		res += '9' * (n - len(res))
		print(res[::-1])
	else:
		res = '8' * (n // 4 + 1)
		res += '9' * (n - len(res))
		print(res[::-1])


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	ans = '8' * ((n + 3) // 4)
	ans = '9' * (n - len(ans)) + ans
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	eight = (n - 1) // 4 + 1
	for __ in range(n - eight):
		print('9', end='')
	for __ in range(eight):
		print('8', end='')
	print()


def con(n):
	m = []
	for h in n:
		h = str(h)
		m.append(h)
	return ''.join(m)
t = int(input())
i = 0
while i < t:
	n = int(input())
	k = []
	if n % 4 == 0:
		x = n // 4
	else:
		x = n // 4 + 1
	for s in range(n):
		if s < n - x:
			k.append(9)
		elif s >= n - x:
			k.append(8)
	print(con(k))
	i += 1


t = int(input())
Ans = []
for i in range(t):
	n = int(input())
	dev_ok = 3 * n // 4
	vosm_ok = n - dev_ok
	x = '9' * dev_ok + '8' * vosm_ok
	Ans.append(x)
for i in Ans:
	print(int(i))


t = int(input())
for qwq in range(t):
	n = int(input())
	z = (n - 1) // 4 + 1
	n = n - z
	print(int('9' * n + '8' * z))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	num8 = (n + 3) // 4
	ans = int('9' * (n - num8) + num8 * '8')
	print(ans)


import math
for tc in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	elif n == 2:
		print(98)
	elif n == 3:
		print(998)
	elif n == 4:
		print(9998)
	else:
		var = math.ceil(n / 4)
		var1 = n - var
		print('9' * var1 + '8' * var)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	cnt8 = ceil(N, 4)
	cnt9 = N - cnt8
	ans = '9' * cnt9 + '8' * cnt8
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	n9 = 3 * n // 4
	n8 = n - n9
	sol = []
	while n9 > 0:
		sol.append('9')
		n9 -= 1
	while n8 > 0:
		sol.append('8')
		n8 -= 1
	print(''.join(sol))
	t -= 1


import math
t = int(input())
while t:
	n = int(input())
	n8 = math.ceil(n / 4)
	print((n - n8) * '9' + n8 * '8')
	t -= 1


for i in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		a = ['8'] * (n // 4)
		p = ['9'] * (3 * (n // 4))
	elif n % 4 == 2:
		a = ['8'] * (n // 4 + 1)
		p = ['9'] * (n - n // 4 - 1)
	elif n % 4 == 1:
		a = ['8'] + ['8'] * (n // 4)
		p = ['9'] * (n - n // 4 - 1)
	else:
		a = ['8'] * (n // 4 + 1)
		p = ['9'] * (n - n // 4 - 1)
	an = p + a
	print(int(''.join(an)))


t = int(input())
while t:
	n = int(input())
	num = []
	for i in range(n - 1):
		num.append(9)
	num.append(8)
	ptr = len(num) - 1
	if n <= 4:
		print(''.join([str(i) for i in num]))
		t -= 1
		continue
	x = n // 4
	for i in range(x):
		num[ptr] = 8
		ptr -= 1
	x = n % 4
	if x == 0:
		print(''.join([str(i) for i in num]))
	else:
		num[ptr] = 8
		print(''.join([str(i) for i in num]))
	t -= 1


t = int(input())
for x in range(t):
	n = int(input())
	k = n // 4
	if n % 4 != 0:
		k += 1
	ans = '9' * (n - k) + '8' * k
	print(ans)


from math import floor
t = int(input())
ns = []
for _ in range(t):
	ns.append(int(input()))
for n in ns:
	e = floor((n + 3) / 4)
	for _ in range(n - e):
		print(9, end='')
	for _ in range(e):
		print(8, end='')
	print()


t = int(input())
while t > 0:
	n = int(input())
	ans = '8' * (n // 4)
	if n % 4 != 0:
		ans += '8'
	ans = '9' * (n - len(ans)) + ans
	print(ans)
	t -= 1


T = int(input())
for t in range(T):
	n = int(input())
	if n % 4 > 0:
		x = n // 4 + 1
	else:
		x = n // 4
	for i in range(n - x):
		print(9, end='')
	for i in range(x):
		print(8, end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	x = max(0, (n - 1) // 4 + 1)
	for i in range(n - x):
		print('9', end='')
	for i in range(x):
		print('8', end='')
	print()


for z in range(int(input())):
	n = int(input())
	p = n // 4
	if n % 4 != 0:
		p += 1
	n -= p
	print('9' * n + '8' * p)


from sys import stdout, stdin
(_input, _print) = (stdin.readline, stdout.write)
(_range, _int, _len, _reversed) = (range, int, len, reversed)

def solution():
	for _ in _range(_int(_input())):
		n = _int(_input())
		digit = [8] * (n // 4)
		if n % 4 > 0:
			digit.append(8)
		else:
			digit.append(9)
		print('9' * (n - _len(digit)), *_reversed(digit), sep='')
solution()


import math
for o in range(int(input())):
	n = int(input())
	s = ''
	x = math.ceil(n / 4)
	for i in range(n - x):
		s = s + '9'
	for i in range(x):
		s = s + '8'
	print(s)


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	else:
		t = (n - 1) // 4
		while n > t + 1:
			print(9, end='')
			n -= 1
		while t >= 0:
			print(8, end='')
			t -= 1
		print()


import math
t = int(input())

def main():
	n = int(input())
	eights = math.ceil(n / 4)
	sec_half = eights * '8'
	first_half = (n - eights) * '9'
	print(first_half + sec_half)
for _ in range(t):
	main()


t = int(input())
for i in range(t):
	N = int(input())
	print(int('9' * (N - (1 + (N - 1) // 4)) + '8' * (1 + (N - 1) // 4)))


t = int(input())
for _ in range(t):
	n = int(input())
	m = n // 4
	r = n % 4
	nc = n - m
	ec = m
	if r > 0:
		nc -= 1
		ec += 1
	num = [9] * nc + [8] * ec
	print(*num, sep='')


t = int(input())
for _ in range(t):
	n = int(input())
	if n % 4 == 0:
		eight = n // 4
	else:
		eight = n // 4 + 1
	nine = n - eight
	print('9' * nine + '8' * eight)


import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

def solve(n):
	if n % 4 == 0:
		res = n // 4
		return '9' * (n - res) + '8' * res
	else:
		res = n // 4 + 1
		return '9' * (n - res) + '8' * res

def main():
	t = int(input())
	arr = []
	for _ in range(t):
		arr.append(solve(int(input())))
	for a in arr:
		print(a)
main()


t = int(input())
res = []
for i in range(t):
	n = int(input())
	a = n // 4
	if n % 4 != 0:
		a += 1
	s = '9' * (n - a) + '8' * a
	res.append(s)
for i in res:
	print(i)


import math

def test_case():
	n = int(input())
	eights = math.ceil(n / 4)
	nines = n - eights
	x = '9' * nines + '8' * eights
	print(x)
T = int(input())
for _ in range(T):
	test_case()


import sys
readline = sys.stdin.buffer.readline
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))

def solve():
	n = ni()
	v = (n - 1) // 4 + 1
	print('9' * (n - v) + '8' * v)
	return
T = ni()
for _ in range(T):
	solve()


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
for _ in range(II()):
	n = II()
	c8 = (n + 3) // 4
	print('9' * (n - c8) + '8' * c8)


import math
t = int(input())
while t:
	n = int(input())
	eight = math.ceil(n / 4)
	for i in range(n - eight):
		print(9, end='')
	for i in range(eight):
		print(8, end='')
	print()
	t = t - 1


import sys
input = sys.stdin.readline

def name(n):
	string = ''
	a = '1000'
	x = ''
	remaining = 0
	while len(string) < n:
		string += a
		x += '8'
		if len(x) > n:
			if n - len(x) > 1:
				x = x[:-1]
				remaining += 1
	remaining += n - len(x)
	while remaining > 0:
		x += '9'
		remaining -= 1
	return x[::-1]

def solution():
	n = int(input())
	print(name(n))
t = int(input())
for i in range(0, t):
	solution()


T = int(input())
for i in range(T):
	n = int(input())
	a = (n + 3) // 4
	ans = '9' * (n - a) + '8' * a
	print(ans)


import sys
input = sys.stdin.readline
for f in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		a = n // 4
	else:
		a = n // 4 + 1
	print(int('9' * (n - a) + '8' * a))


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	hashm = {}
	arr = []
	heapq.heapify(arr)
	for test in range(tests):
		n = inp()
		nine = n - n // 4
		eight = n // 4
		x = '9' * (nine - 1)
		if n % 4 == 0:
			x = x + '9'
		else:
			x = x + '8'
		x = x + '8' * eight
		print(x)
main()


import math
for cases in range(int(input())):
	n = int(input())
	if n == 1:
		print('8')
	else:
		remain = math.ceil(n / 4)
		print('9' * (n - remain) + '8' * remain)


from sys import stdin
import math
for _ in range(int(input())):
	n = int(stdin.readline().rstrip())
	z = math.ceil(n / 4)
	print('9' * (n - z) + '8' * z)


from math import ceil
for i in range(int(input())):
	a = int(input())
	q = ceil(a / 4)
	print('9' * (a - q) + '8' * q)


t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		print(8)
	elif n == 2:
		print(98)
	elif n == 3:
		print(998)
	elif n == 4:
		print(9998)
	else:
		b = n * 4
		n1 = n // 4
		n1 += 1
		t1 = ''
		if n % 4 == 0:
			for i in range(n - n1 + 1):
				t1 += '9'
			for i in range(n1 - 1):
				t1 += '8'
		else:
			for i in range(n - n1):
				t1 += '9'
			for i in range(n1):
				t1 += '8'
		print(int(t1))


t = int(input())
for i in range(t):
	s = ''
	n = int(input())
	k = 3 * n / 4
	for i in range(int(k)):
		s += '9'
	if n % 4 != 0:
		s += '8'
	for i in range(int(n / 4)):
		s += '8'
	print(int(s), end='\n')


for ii in range(int(input())):
	n = int(input())
	ei = (n - 1) // 4 + 1
	ni = n - ei
	ans = int('9' * ni + '8' * ei)
	print(ans)


from sys import stdin

def to_base10(n, m):
	i = 0
	for s in n:
		i *= m
		i += int(s)
	return i

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		N = int(input())
		x = '9' * N
		k = []
		for s in x:
			k.append(format(int(s), 'b'))
		n = (N + 3) // 4
		for i in range(1, n + 1):
			k[-i] = '8'
		for s in k:
			print(to_base10(s, 2), end='')
		print()
main()


def kosty(n):
	m = 4 * n - n
	f = m // 4
	r = m % 4
	g = n // 4
	if r == 0:
		return f * '9' + '8' * g
	else:
		return f * '9' + '8' * (g + 1)
t = int(input())
for test in range(t):
	n = int(input())
	print(kosty(n))


from math import sqrt
for _ in range(int(input())):
	n = int(input())
	s = ''
	x = n // 4
	if n % 4 != 0:
		x += 1
	for i in range(n - x):
		s += '9'
	for i in range(x):
		s += '8'
	print(s)


def solve(n):
	m = n // 4
	if n % 4 != 0:
		m += 1
	l = '9' * (n - m) + '8' * m
	return l
t = int(input())
for we in range(t):
	n = int(input())
	print(solve(n))


from sys import stdin
t = int(stdin.readline().strip())
for _ in range(t):
	n = int(stdin.readline().strip())
	x = [9] * n
	num8 = 0 if n % 4 == 0 else 1
	num0 = int(n // 4)
	num9 = n - num8 - num0
	print('9' * num9 + '8' * (num8 + num0))


import sys
input = sys.stdin.buffer.readline
from math import *
t = int(input())
while t:
	t -= 1
	n = int(input())
	c = int(ceil(n / 4))
	rest = n - c
	for i in range(rest):
		print('9', end='')
	for i in range(c):
		print('8', end='')
	print()


def closest_number(num, m):
	if num % m == 0:
		return num
	else:
		return num + (m - num % m)
t = int(input())
while t:
	n = int(input())
	div = closest_number(n, 4) // 4
	s = '9' * (n - div) + '8' * div
	print(s)
	t -= 1


import math
for _ in range(int(input())):
	n = int(input())
	x = ''
	y = int((n + 3) / 4)
	for i in range(n - y):
		x = x + '9'
	for i in range(y):
		x = x + '8'
	print(int(x))


for t in range(int(input())):
	n = int(input())
	if n % 4 != 0:
		p = n // 4 + 1
	else:
		p = n // 4
	num = '9' * (n - p) + '8' * p
	print(int(num))


import math
t = int(input())
for z in range(t):
	n = int(input())
	number_nine = int(3 * n / 4)
	for i in range(n):
		if i >= number_nine:
			print(8, end='')
		else:
			print(9, end='')
	print()


N = int(input())
for i in range(N):
	n = int(input())
	b = int((n + 3) // 4)
	print('9' * (n - b) + '8' * b)


def main():
	for _ in range(int(input())):
		n = int(input())
		l = [9] * n
		l1 = []
		for i in range(n):
			l1.extend(list(bin(l[i]))[2:])
		w = []
		for i in range(n):
			w.append(l1.pop())
		w = w[::-1]
		j = -1
		for i in range(len(w) // 4):
			l[j] = 8
			j -= 1
		if len(w) % 4 != 0:
			l[j] = 8
		print(*l, sep='')
main()


for i in [0] * int(input()):
	a = int(input())
	b = int(-(-a // 4))
	print('9' * (a - b) + '8' * b)


from sys import stdin, stdout
import math
from collections import defaultdict
from collections import Counter

def arrinp():
	return [*map(int, stdin.readline().split(' '))]

def mulinp():
	return map(int, stdin.readline().split(' '))

def intinp():
	return int(stdin.readline())

def inp():
	return stdin.readline()

def solution():
	n = intinp()
	val = (n - 1) // 4
	ans = 0
	for i in range(n - val - 1):
		print(9, end='')
	for i in range(val + 1):
		print(8, end='')
	print()
testcases = 1
testcases = intinp()
for _ in range(testcases):
	solution()


import math
ceil = math.ceil
t = int(input())
for x in range(t):
	n0 = int(input())
	number = (n0 - 1) // 4 + 1
	print('9' * (n0 - number) + '8' * number)


for t in range(int(input())):
	n = int(input())
	le = (n - 1) // 4 + 1
	wa = '9' * (n - le) + '8' * le
	print(wa)


def main():
	n = int(input())
	num = n * 4
	num = num - n
	string = '9' * (num // 4)
	for _ in range(n - len(string)):
		string += '8'
	print(string)

def test():
	t = int(input())
	while t:
		main()
		t -= 1
	return
test()


import sys
import math, bisect
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	t = math.ceil(n / 4)
	print((n - t) * '9' + t * '8')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	n = int(inp())
	a = []
	for i in range(n):
		a.append(9)
	for i in range(n - 1, n - n // 4 - 1, -1):
		a[i] = 8
	if n % 4 != 0:
		a[n - n // 4 - 1] = 8
	print(''.join((str(a[i]) for i in range(n))))
testcase(int(inp()))


for i in range(int(input())):
	n = int(input())
	num = str(9) * n
	num = list(num)
	k = n // 4
	if n % 4 == 0:
		num = num[:-k]
		num = num + list(k * str(8))
	else:
		num = num[:-k - 1]
		num = num + list((k + 1) * str(8))
	print(''.join(num))


import math
t = int(input().split()[0])
for case in range(t):
	n = int(input().split()[0])
	print('9' * (n - math.ceil(n / 4)) + '8' * math.ceil(n / 4))


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
sys.setrecursionlimit(10 ** 6)
from queue import PriorityQueue
from collections import Counter as cc
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
import sys
t = int(input())
for _ in range(t):
	n = int(input())
	z1 = ceil(n / 4)
	ans = '9' * (n - z1) + '8' * z1
	print(ans)


(T,) = map(int, input().split())
for _ in range(T):
	(N,) = map(int, input().split())
	c = -(-N // 4)
	print('9' * (N - c) + '8' * c)


from math import ceil
t = int(input())
for _ in range(t):
	n = int(input())
	eight = ceil(n / 4)
	print('9' * (n - eight), end='')
	print('8' * eight)


def solve():
	n = int(input())
	if n % 4 != 0:
		notmatter = n // 4 + 1
	else:
		notmatter = n // 4
	ans = '9' * (n - notmatter)
	ans += '8' * notmatter
	return ans
T = int(input())
for i in range(T):
	print(solve())


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	num_8s = (n + 3) // 4
	num_9s = n - num_8s
	print('9' * num_9s + '8' * num_8s)


from sys import stdin, stdout
import math
from collections import Counter, defaultdict
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()

def case():
	n = IN()
	print('9' * (n - math.ceil(n / 4)) + '8' * math.ceil(n / 4))
for _ in range(IN()):
	case()


import sys, math
T = int(input())
for _ in range(T):
	n = int(input())
	x = math.ceil(n / 4)
	s = '9' * (n - x) + '8' * x
	print(s)


import math

def solve():
	n = int(input().strip())
	eigths = int(math.ceil(n / 4))
	nines = n - eigths
	print('9' * nines + '8' * eigths)
t = int(input().strip())
for _ in range(t):
	solve()


def solve(n):
	import math
	n8 = math.ceil(n / 4)
	n9 = n - n8
	return '9' * n9 + '8' * n8

def main(istr, ostr):
	t = int(istr.readline().strip())
	for _ in range(t):
		n = int(istr.readline().strip())
		result = solve(n)
		print(result, file=ostr)
import sys
main(sys.stdin, sys.stdout)


t = int(input())
for _ in range(t):
	x = int(input())
	result = []
	needed = x // 4
	if x % 4:
		needed += 1
	nine = x - needed
	for _ in range(nine):
		result.append('9')
	for _ in range(needed):
		result.append('8')
	print(''.join(result))


import math

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		numEights = math.ceil(n / 4)
		result = '9' * (n - numEights) + '8' * numEights
		print(result)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	e = 0
	e = n // 4
	if n % 4 > 0:
		e += 1
	for i in range(n - e):
		print(9, end='')
	for i in range(e):
		print('8', end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	x_arr = ['9'] * n
	digit_changes = (n - 1) // 4 + 1
	for i in range(len(x_arr) - 1, len(x_arr) - 1 - digit_changes, -1):
		x_arr[i] = '8'
	print(''.join(x_arr))


for _ in range(int(input())):
	n = int(input())
	l = [9] * n
	b = n // 4
	if n % 4 != 0:
		b += 1
	for i in range(0, b):
		l[i] = 8
	l = reversed(l)
	s = ''.join([str(i) for i in l])
	s = int(s)
	print(s)


for t in range(int(input())):
	n = int(input())
	x = (n + 3) // 4
	x = n - x
	count = 0
	res = ''
	for i in range(n):
		if count == x:
			res += '8'
		else:
			count += 1
			res += '9'
	print(res)


from math import *
for i in range(int(input())):
	k = int(input())
	w = ceil(k / 4)
	print('9' * (k - w) + '8' * w)


t = int(input())
for i in range(t):
	x = int(input())
	ans = 8
	u = 0
	an = ''
	n = 0
	if x <= 4:
		for i in range(u + 1, x):
			ans += 9 * 10 ** i
		print(ans)
	else:
		a = ''
		q = (x - 1) // 4
		a += '9' * (x - q - 1)
		a += '8' * (q + 1)
		print(int(a))


import sys
input = sys.stdin.readline
from math import gcd
import math
t = int(input())
for ccc in range(t):
	x = int(input())
	t = x // 4
	if x % 4 > 0:
		t += 1
	print((x - t) * '9' + t * '8')


for i in range(int(input())):
	n = int(input())
	p1 = (n + 3) // 4
	p2 = n - p1
	s = ''
	for i in range(p2):
		s += '9'
	for i in range(p1):
		s += '8'
	print(int(s))


for i in ' ' * int(input()):
	a = int(input())
	z = (a + 3) // 4
	print('9' * (a - z) + '8' * z)


try:
	t = int(input())
	while t != 0:
		n = int(input())
		if n == 1:
			print('8')
		elif n == 2:
			print('98')
		else:
			p = n // 4
			if n % 4 > 0:
				s = p + 1
				ss = '9' * (n - s) + '8' * s
				print(ss)
			else:
				s = p
				ss = '9' * (n - s) + '8' * s
				print(ss)
		t = t - 1
except EOFError:
	print(' ')


try:
	t = int(input())
	while t:
		n = int(input())
		if n % 4 == 0:
			f = n // 4
		else:
			f = n // 4 + 1
		s = '9'
		e = '8'
		r = n - f
		h = r * s + f * e
		print(h)
		t -= 1
except:
	pass


import math
t = int(input())
for i in range(t):
	N = int(input())
	for i in range(N - math.ceil(N / 4)):
		print('9', end='')
	for i in range(math.ceil(N / 4)):
		print('8', end='')
	print()


from math import ceil
for _ in range(int(input())):
	n = int(input())
	string = '9' * n
	string = string[:-1 * ceil(n / 4)] + '8' * ceil(n / 4)
	print(string)


import sys
sys.setrecursionlimit(10000)
t = int(input())
for _ in range(t):
	n = int(input())
	remain = n % 4
	times = n // 4
	y = '8' * times
	z = ''
	if remain != 0:
		z = '8'
	digleft = n - times - 1
	if remain == 0:
		digleft += 1
	x = '9' * digleft
	x = x + z + y
	print(x)


for _ in range(0, int(input())):
	n = int(input())
	if n == 1:
		print(8)
	elif n == 2:
		print(98)
	elif n == 3:
		print(998)
	else:
		import math
		k = n // 4
		minuss = int(math.ceil(n / 4))
		r = '8' * minuss
		print('9' * (n - minuss) + r)


t = int(input())
for _ in range(t):
	n = int(input())
	count = n // 4
	if n % 4 != 0:
		count += 1
	print('9' * (n - count), end='')
	print('8' * count)


for _ in range(int(input())):
	n = int(input())
	qt = n // 4
	rem = n % 4
	if rem != 0:
		qt += 1
	left = n - qt
	print('9' * left + '8' * qt)


from sys import *
input = stdin.readline
t = int(input())
p = []
for _ in range(t):
	n = int(input())
	x = n // 4
	if n % 4 != 0:
		x += 1
	s = '9' * (n - x) + '8' * x
	print(s)


import math
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
	else:
		q = n // 4
		r = n % 4
		ans = '9' * (n - q - 1)
		if r == 1:
			ans += '8'
		elif r == 2:
			ans += '8'
		elif r == 3:
			ans += '8'
		else:
			ans += '9'
		ans += '8' * q
		print(ans)


from sys import stdin, stdout
import math
input = stdin.readline

def solve():
	n = int(input())
	if n == 1:
		print('8')
	else:
		print('9' * (n - math.ceil(n / 4)) + '8' * math.ceil(n / 4))
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


def redt(s):
	if s[0] == '0':
		return '8'
	u = int(s[0]) * 8 + int(s[1]) * 4 + int(s[2]) * 2 + int(s[3]) * 1
	return str(u)
for _ in range(int(input())):
	n = int(input())
	s = ''
	tr = '1001'
	for i in range(n):
		s += tr
	fr = s[:-1 * n] + '0' * n
	gt = ''
	for i in range(n):
		gt += redt(fr[i * 4:(i + 1) * 4])
	print(gt)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, k, m):
	res = 1
	while k > 0:
		if k % 2 == 1:
			res = res * a % m
		a = a * a % m
		k = k // 2
	return res % m

def solution():
	n = int(input())
	s = '8'
	temp = n
	three = temp // 4
	temp = temp - three * 4
	if temp > 0:
		left = n - (three + 1)
	else:
		left = n - three
	ss = '9' * left
	if temp > 0:
		if temp == 1:
			ss += '8'
		elif temp == 2:
			ss += '8'
		else:
			ss += '8'
	ss += '8' * three
	print(ss)
for i in range(int(input())):
	solution()


def solve():
	n = int(input())
	v = (n - 1) // 4 + 1
	u = n - v
	print('9' * u, '8' * v, sep='')
t = int(input())
for _ in range(t):
	solve()


import sys
input = sys.stdin.readline
T = int(input())
for testcase in range(1, T + 1):
	n = int(input())
	dg = 1
	k = n
	res = ['0'] * n
	for i in range(n):
		if k > 0:
			res[n - 1 - i] = '8'
		else:
			res[n - 1 - i] = '9'
		k -= 4
	print(''.join(res))


t = int(input())
for _ in range(t):
	n = int(input())
	sum = (n - 1) // 4 + 1
	print('9' * (n - sum), end='')
	print('8' * sum)


for _ in range(int(input())):
	n = int(input())
	c = 0
	string = ''
	for i in range(0, n, 4):
		string = '1000' + string
		c += 1
	print('9' * (n - c) + '8' * c)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
from math import ceil, floor, sqrt
for _ in range(N()):
	n = N()
	t = ceil(n / 4)
	print(int('9' * (n - t) + '8' * t))


import sys
import math
from functools import reduce
import bisect

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def input():
	return sys.stdin.readline().rstrip()

def index(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return False
for _ in range(int(input())):
	n = getN()
	s = '8' * (n // 4) + ('8' if n % 4 else '')
	t = n - (n // 4 + (1 if n % 4 else 0))
	s = t * '9' + s
	print(s)


t = int(input(''))
for i in range(t):
	s = ''
	n = int(input(''))
	n8 = int(n // 4)
	if n % 4 != 0:
		n8 += 1
	n9 = n - n8
	for i in range(n9):
		s += '9'
	for i in range(n8):
		s += '8'
	print(s)


for _ in range(int(input())):
	n = int(input())
	for i in range(n):
		d = '8'
		if i * 4 + 3 < n * 3:
			d = '9'
		print(end=d)
	print()


from math import ceil
t = int(input())
while t > 0:
	n = int(input())
	l = []
	for i in range(0, ceil(n / 4)):
		l.append(8)
	for i in range(0, n - ceil(n / 4)):
		l.append(9)
	for item in reversed(l):
		print(item, end='')
	print('')
	t -= 1


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(10240000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		n = ii()
		l = []
		x = 4 * n - n
		cnt = 0
		flag = 0
		for i in range(n):
			if flag:
				l.append(8)
				continue
			if cnt + 4 > x:
				p = x - cnt
				if p == 1:
					l.append(8)
				elif p == 2:
					l.append(8)
				elif p == 3:
					l.append(8)
				elif p == 0:
					l.append(8)
				flag = 1
			else:
				l.append(9)
				cnt += 4
		for i in l:
			print(i, end='')
		print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(int(input())):
	n = stdint()
	res = ['9'] * n
	d = n // 4
	if n % 4 != 0:
		d += 1
	for i in range(d):
		res[n - i - 1] = '8'
	r = ''.join(res)
	print(r)


from sys import stdin, stdout
input = stdin.readline

def ceil(a, b):
	return (a + b - 1) // b
t = int(input())
for _ in range(t):
	n = int(input())
	x = ceil(n, 4)
	stdout.write('9' * (n - x) + '8' * x + '\n')


def process(n):
	e = (n - 1) // 4 + 1
	n = n - e
	for i in range(n):
		print('9', end='')
	for i in range(e):
		print('8', end='')
	print()
tests = int(input())
for i in range(tests):
	n = int(input())
	process(n)


t = int(input())
n = tuple((int(input()) for i in range(t)))
for i in range(t):
	k = (n[i] - 1) // 4 + 1
	print('9' * (n[i] - k) + '8' * k)


t = int(input())
for i in range(t):
	n = int(input())
	if n % 4 == 0:
		m = n // 4
	else:
		m = n // 4 + 1
	print(int(str('9' * (n - m)) + '8' * m))


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = ['9'] * n
	p = n - 1
	while n > 0:
		n -= 4
		s[p] = '8'
		p -= 1
	print(''.join(s))


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	print('9' * (n - n // 4 - int(n % 4 != 0)) + '8' * int(n % 4 != 0) + '8' * (n // 4))


def binaryToDecimal(n):
	num = n
	dec_value = 0
	base1 = 1
	len1 = len(num)
	for i in range(len1 - 1, -1, -1):
		if num[i] == '1':
			dec_value += base1
		base1 = base1 * 2
	return dec_value

def decimalToBinary(n):
	return bin(n).replace('0b', '')
t = int(input())
for _ in range(t):
	n = int(input())
	s = ''
	for i in range(n):
		s = s + '9'
	b = ''
	for i in range(n):
		b = b + decimalToBinary(9)
	ans = ''
	for i in range(n):
		ans = ans + '0'
	final = ''
	for i in range(len(b) - n):
		final = final + b[i]
	final = final + ans
	ese = ''
	for i in range(int(len(final) / 4)):
		num = binaryToDecimal(final[4 * i:4 * i + 4])
		if num == 0:
			num = 8
		ese = ese + str(num)
	print(ese)


def solve(n):
	pow_8 = n // 4
	if n % 4 == 0:
		pow_8 -= 1
	for i in range(n - 1 - pow_8):
		print(9, end='')
	for i in range(pow_8 + 1):
		print(8, end='')
	print()
t = int(input())
for i in range(t):
	n = int(input())
	solve(n)


import sys
read = sys.stdin.buffer.read
readlines = sys.stdin.buffer.readlines
t = int(input())
for case in range(t):
	n = int(input())
	k = 1 + (n - 1) // 4
	ans = '9' * (n - k) + '8' * k
	print(ans)


import math

def Calculate(n):
	x = n / 4
	if x == int(x):
		x = x - 1
	k = int(x) + 1
	Str = ''
	for i in range(n - k):
		Str = Str + '9'
	for i in range(k):
		Str = Str + '8'
	print(Str)
Trials = int(input(''))
for i in range(Trials):
	n = int(input(''))
	Calculate(n)


from math import ceil
for _ in range(int(input())):
	n = int(input())
	t1 = ceil(n / 4)
	for i in range(n - t1):
		print('9', end='')
	print('8' * t1)


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(8)
		continue
	s = 3 * n // 4
	print('9' * s + '8' * (n - s))


import sys
lines = sys.stdin.read().splitlines()
lincnt = -1

def line():
	global lincnt
	lincnt += 1
	return lines[lincnt]
for _ in range(int(line())):
	n = int(line())
	e = (n + 3) // 4
	print(''.join('9' * (n - e) + '8' * e))


t = int(input())
for _ in range(t):
	n = int(input())
	s = '1001' * n
	s = s[:len(s) - n]
	s += '0' * n
	u = ''
	for i in range(0, len(s) - 3, 4):
		v = s[i:i + 4]
		if v == '0000':
			v = '1000'
		u += str(int(v, 2))
	print(u)


import math
for _ in range(int(input())):
	n = int(input())
	x8 = math.ceil(n / 4)
	x9 = n - x8
	ans = ''
	for i in range(n):
		if x9 != 0:
			ans += '9'
			x9 -= 1
		else:
			ans += '8'
			x8 -= 1
	print(int(ans))


for i in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		c = n // 4
	else:
		c = n // 4 + 1
	l = [9] * (n - c)
	l2 = [8] * c
	l3 = l + l2
	print(*l3, sep='')


from math import ceil

def solve():
	n = int(input())
	ei = ceil(n / 4.0)
	print('9' * (n - ei) + '8' * ei)
for _ in range(int(input())):
	solve()


import math
t = int(input())
r = []
for i in range(t):
	n = int(input())
	b = math.ceil(n / 4)
	a = ['9'] * (n - b)
	c = ['8'] * b
	a = a + c
	ac = ''.join(a)
	r.append(ac)
for i in range(len(r)):
	print(r[i])


import math
t = int(input())
while t:
	t = t - 1
	n = int(input())
	e8s = math.ceil(n / 4)
	n9s = n - e8s
	s = '9' * n9s + '8' * e8s
	print(s)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
from itertools import accumulate
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	ans = deque()
	last = -1
	for i in range(n):
		ans.appendleft(9)
		if i % 4 == 0:
			ans[last] = 8
			last -= 1
	print(*ans, sep='')


import math
for _ in range(int(input())):
	ns = input()
	n = int(ns)
	n8 = math.ceil(n / 4)
	print('9' * (n - n8), '8' * n8, sep='')


from __future__ import division, print_function
import os, sys
import math
import collections
from itertools import permutations
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

class my_dictionary(dict):

	def __init__(self):
		self = dict()

	def add(self, key, value):
		self[key] = value

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return -1

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(my_list):
	freq = {}
	for item in my_list:
		if item in freq:
			freq[item] += 1
		else:
			freq[item] = 1
	return freq

def pos(a):
	b = [0] * len(a)
	c = sorted(a)
	for i in range(len(a)):
		for j in range(len(a)):
			if c[j] == a[i]:
				b[i] = j
				break
	return b

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def commonn(a, b, n):
	c = []
	for i in range(n):
		if a[i] == b[i]:
			c.append('-1')
		else:
			c.append(b[i])
	return c

def primeFactors(n):
	j = []
	while n % 2 == 0:
		j.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			j.append(int(n))
			n = n / i
	if n > 2:
		j.append(int(n))
	return j

def sumdigit(n):
	n = str(n)
	k = 0
	for i in range(len(n)):
		k += int(n[i])
	return k

def question(a, n):
	j = a
	for i in range(n):
		if a[i] == '1':
			j[i] = '0'
		else:
			j[i] = '1'
	j[0, n - 1].reverse()
	return j

def main():
	for _ in range(ii()):
		n = ii()
		kl = n
		b = []
		jk = math.ceil(n / 4)
		print('9' * (n - jk), end='')
		print('8' * jk)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	a = int(input())
	d = a // 4
	if a % 4 == 0:
		pass
	else:
		d += 1
	n = ['9'] * (a - d)
	f = ['8'] * d
	n.extend(f)
	print(''.join(n))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	if n <= 4:
		s = '9' * (n - 1)
		s += '8'
	if n > 4:
		(q, r) = divmod(n, 4)
		if r == 0:
			q -= 1
		s = '9' * (n - 1 - q)
		s += '8' * (1 + q)
	print(s)


test = int(input())

def solve():
	n = int(input())
	nine = (n + 3) // 4
	for x in range(n - nine):
		print(9, end='')
	for x in range(nine):
		print(8, end='')
	print('')
for x in range(test):
	solve()


from sys import stdin
n = int(stdin.readline().strip())
for i in range(n):
	x = int(stdin.readline().strip())
	z = x // 4
	if x % 4 != 0:
		z += 1
	print('9' * (x - z) + '8' * z)


import sys
input = sys.stdin.readline

def main(a):
	(times, rem) = divmod(a, 4)
	num = ''
	if rem > 0:
		num = '9' * (a - times - 1) + '8' * (times + 1)
	else:
		num = '9' * (a - times) + '8' * times
	return num
for _ in range(int(input())):
	a = int(input())
	print(main(a))


import sys
input = sys.stdin.readline
from collections import *
for _ in range(int(input())):
	n = int(input())
	if n % 4 == 0:
		print('9' * (n - n // 4) + '8' * (n // 4))
	else:
		print('9' * (n - n // 4 - 1) + '8' + '8' * (n // 4))


from math import ceil
t = int(input())
for j in range(t):
	sudheer = int(input())
	p = ceil(sudheer / 4)
	print('9' * (sudheer - p) + '8' * p)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	v = n // 4 + (1 if n % 4 else 0)
	print('9' * (n - v) + '8' * v)


for _ in range(int(input())):
	x = int(input())
	y = ('1001' * x)[:-x] + '0' * x
	t = y.count('1001')
	print('9' * t + '8' * (x - t))


for _ in range(int(input())):
	n = int(input())
	x = n
	y = (n - 1) // 4
	y += 1
	while n:
		if n > y:
			print(9, end='')
		else:
			print(8, end='')
		n -= 1
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	c = n // 4
	d = n % 4
	if d:
		c += 1
	else:
		pass
	print('9' * (n - c) + '8' * c)


import math
import sys
import bisect
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	req = n * 4
	req -= n
	for i in range(req // 4):
		print('9', end='')
	for i in range(n - req // 4):
		print('8', end='')
	print()


import math
for i in range(int(input())):
	n = int(input())
	if n <= 4:
		print('9' * (n - 1) + '8')
		continue
	s = '8' * math.ceil(n / 4)
	print('9' * (n - len(s)) + s)


import sys
import math
mod = 10 ** 9 + 7
inf = float('inf')

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))
t = I()
for _ in range(t):
	n = I()
	m = 4 * n
	l = (n - 1) // 4 + 1
	ans = [str(9) for _ in range(n - l)]
	for _ in range(l):
		ans.append(str(8))
	print(''.join(ans))


from collections import Counter
import math
array = [6, 10, 14, 15]
for _ in range(int(input())):
	n = int(input())
	x = math.ceil(n / 4)
	s = ''
	s += (n - x) * '9' + x * '8'
	print(s)


import sys
from math import sqrt
inpt = sys.stdin.readline

def inp():
	return int(inpt())

def inlist():
	return list(map(int, inpt().split()))

def instr():
	s = inpt()
	return list(s[:len(s) - 1])

def invr():
	return map(int, inpt().split())

def main():
	t = inp()
	for l in range(t):
		n = inp()
		x = n / 4
		for i in range(int(n - x)):
			print(9, sep='', end='')
		for i in range(int(x + 0.999)):
			print(8, sep='', end='')
		print()
main()


test = int(input())
for _ in range(test):
	n = int(input())
	b = n // 4
	c = n % 4
	ans = '8' * b
	n -= b
	if c:
		ans = '8' + ans
		n -= 1
	ans = '9' * n + ans
	print(int(ans))


ans = []
for _ in range(int(input())):
	n = int(input())
	ansi = '9' * (3 * n // 4) + '8' * ((n - 1) // 4 + 1)
	ans.append(ansi)
print('\n'.join(ans))