Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.

Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony.

He would like to find a positive integer n not greater than 10^18, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist.

A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms.

 $0123456789$ 


-----Input-----

The first and only line contains an integer k (1 ≤ k ≤ 10^6) — the desired number of loops.


-----Output-----

Output an integer — if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 10^18.


-----Examples-----
Input
2

Output
462
Input
6

Output
8080

Source: codeforces | Difficulty: EASY
Tags: Implementation

Constructive algorithms


Solutions:
import sys
k = int(input())
if k > 36:
	print(-1)
	sys.exit()
if k % 2 == 0:
	print('8' * (k // 2))
else:
	print('4' + '8' * (k // 2))


n = int(input())
if n % 2 == 0:
	a = '8' * (n // 2)
else:
	a = '8' * (n // 2) + '4'
if len(a) > 18:
	print(-1)
else:
	print(a)


k = int(input())
if k > 36:
	print(-1)
else:
	print('8' * (k // 2) + '6' * (k % 2))


k = int(input())
if k > 40:
	print(-1)
elif k == 0:
	print(1)
elif k == 1:
	print(6)
else:
	s = '8' * (k // 2) + '6' * (k % 2)
	if int(s) > 10 ** 18:
		print(-1)
	else:
		print(s)


k = int(input())
if k / 2 > 18:
	print(-1)
else:
	print('8' * (k // 2), '9' * (k % 2), sep='')


k = int(input())
if k > 36:
	print(-1)
	exit()
res = ''
res = res + '8' * (k // 2)
res = res + '9' * (k % 2)
print(res)


import sys
p = input()
k = int(p)
if k >= pow(10, 6):
	print(-1)
	sys.exit(0)
if k % 2 == 0:
	k = k // 2
	t = '8' * k
	if int(t) > pow(10, 18):
		print(-1)
		sys.exit(0)
	print(t)
	sys.exit(0)
else:
	k = k // 2
	t = '8' * k + '6'
	if int(t) > pow(10, 18):
		print(-1)
		sys.exit(0)
	print(t)
	sys.exit(0)


k = list(map(int, input().split()))[0]

def func(x):
	powers = []
	i = 1
	while i <= x:
		if i & x:
			powers.append(i)
		i <<= 1
	return powers
d = {}
d[0] = 1
d[1] = 0
d[1] = 4
if k > 36:
	print(-1)
elif k == 0:
	print(1)
elif k % 2 == 0:
	for i in range(k // 2):
		print(8, end='')
	print()
else:
	tp = func(k)
	ans = ''
	for i in tp:
		if i % 2 == 0:
			for j in range(i // 2):
				ans += '8'
		else:
			ans += str('4')
	print(ans)


def main():
	k = int(input())
	if k > 36:
		n = '-1'
	else:
		n = '8' * (k // 2) + '4' * (k % 2)
	print(n)
main()


def string(k):
	if k > 36:
		return -1
	s = ''
	if k == 0:
		return 4
	while k > 0:
		if k == 1:
			s += '4'
			break
		else:
			s += '8'
			k -= 2
	return int(s)
k = int(input())
print(string(k))


x = input()
x = int(x)
c = ''
if x >= 37:
	c = '-1'
elif x % 2 == 0:
	c = '8' * int(x / 2)
else:
	c = '8' * int((x - 1) / 2)
	c += '4'
print(c)


k = int(input(''))
if k > 36:
	print('-1')
elif k > 0:
	if k % 2 == 0:
		print('8' * (k // 2))
	else:
		print('8' * (k // 2) + '4')


n = int(input())
if n > 36:
	print(-1)
else:
	while n > 0:
		if n % 2 == 0:
			print(8, end='')
			n -= 2
		else:
			print(6, end='')
			n -= 1


n = int(input())
if n > 36:
	print(-1)
elif n % 2 == 0:
	print('8' * (n // 2))
elif n == 1:
	print(6)
else:
	print('8' * ((n - 1) // 2) + '0')


i = int(input())
c = '8' * (i // 2) + '6' * (i % 2)
print(c if i <= 36 else -1)


from sys import stdin
n = int(stdin.readline().strip())
ans = ''
lim = 10 ** 18
while n > 0 and (ans == '' or int(ans) <= lim):
	if n >= 2:
		ans += '8'
		n -= 2
	else:
		n -= 1
		ans += '4'
if n == 0 and (ans == '' or int(ans) <= lim):
	print(ans)
else:
	print(-1)


k = int(input())
if k > 36:
	print(-1)
elif k <= 18:
	print('1' + '0' * k)
else:
	print('8' * (k - 18) + '0' * (36 - k))


n = int(input())
d = {0: 1, 1: 0, 2: 0, 3: 0, 4: 1, 5: 0, 6: 1, 7: 0, 8: 2, 9: 1}
s = ''
if n >= 37:
	print(-1)
elif n % 2 == 0:
	s += '8' * (n // 2)
	print(s)
else:
	s += '8' * (n // 2)
	s += '6'
	print(s)


from math import ceil
n = int(input())
if n > 36:
	print(-1)
else:
	print('8' * (n // 2), end='')
	if n % 2 == 1:
		print('4')


n = int(input())
num = ''
if n >= 37:
	print(-1)
elif n % 2 == 0:
	num += '8' * (n // 2)
	print(num)
else:
	num += '4'
	num += '8' * (n // 2)
	print(num)


n = int(input())
if n > 36:
	print(-1)
elif n % 2 == 1:
	print('4' + '8' * (n // 2))
else:
	print('8' * (n // 2))


n = int(input())
if n > 36:
	print(-1)
else:
	s = ''
	s = int(n / 2) * '8' + n % 2 * '4'
	print(s)


n = int(input())
if n > 36:
	print(-1)
	exit()
else:
	out = '8' * (n // 2)
	if n % 2 != 0:
		out += '6'
print(out)


import math
k = int(input())
e = math.pow(10, 18)
f = 0
s = ''
if k > 36:
	print(-1)
elif k == 0:
	print(1)
elif k == 1:
	print(6)
elif k == 2:
	print(8)
elif k % 2 != 0:
	for i in range(k // 2):
		s += '8'
		if int(s) >= e:
			print(-1)
			f = 1
			break
	if f == 0:
		print(s + '4')
else:
	for i in range(k // 2):
		s += '8'
		if int(s) >= e:
			print(-1)
			f = 1
			break
	if f == 0:
		print(s)


innum = int(input())
if innum > 36:
	ans = '-1'
elif innum % 2 == 0:
	ans = '8' * (innum // 2)
else:
	ans = '8' * (innum // 2) + '4'
print(ans)


k = int(input())
x = ''
if k >= 37:
	print(-1)
elif k % 2 == 0:
	for i in range(0, k // 2 - 1):
		x += '8'
	x += '8'
	print(x)
else:
	for i in range(0, k // 2):
		x += '8'
	x += '6'
	print(x)


def generate_num(loops):
	if loops not in range(1, 1000001):
		return -1
	num = ''
	len = 0
	while loops != 0:
		if loops >= 2:
			num += str(8)
			len += 1
			loops -= 2
		elif loops >= 1:
			num += str(9)
			len += 1
			loops -= 1
		if len > 18:
			return -1
	return num
loops = generate_num(int(input()))
print(loops)


inp = int(input())
output = ''
flag = False
if inp > 36:
	print(-1)
	flag = True
if inp == 0:
	print(1)
	flag = True
if inp == 1:
	print(4)
	flag = True
if flag == False:
	while inp != 0:
		if inp >= 2:
			output = output + '8'
			inp -= 2
		else:
			output = output + '0'
			inp -= 1
	print(output)


import sys
n = int(input())
if n > 36:
	print(-1)
	sys.exit()
ds = ['8'] * (n // 2)
if n % 2 == 1:
	ds.append('4')
print(int(''.join(ds)))


n = int(input())
res = '-1'
if n == 0:
	res = '1'
if n == 1:
	res = '6'
if n > 1 and n // 2 + n % 2 < 19:
	res = n // 2 * '8' + n % 2 * '0'
print(res)


n = int(input())
answer = ''
if n > 36:
	print(-1)
else:
	while n != 0:
		if n >= 2:
			n -= 2
			answer += '8'
		else:
			n -= 1
			answer += '4'
print(answer)


import sys
n = int(input())
if n > 36:
	print(-1)
	sys.exit()
ans = ''
while n >= 2:
	ans += '8'
	n -= 2
while n >= 1:
	ans += '4'
	n -= 1
if len(ans) > 20 or int(ans) > 10 ** 18:
	print(-1)
	sys.exit()
else:
	print(ans)


loops = int(input())
if loops > 18 * 2:
	print(-1)
else:
	acc = []
	while loops > 1:
		acc.append('8')
		loops -= 2
	if loops == 1:
		acc.append('4')
	print(''.join(acc))


result = [' ' for i in range(18)]
k = int(input())
n = 0
i = 0
while n < k and result.count('8') != 18:
	n += 1
	if i == 18:
		i = 0
	if result[i] == ' ':
		result[i] = '6'
	elif result[i] == '6':
		result[i] = '8'
	else:
		n -= 1
	i += 1
if n == k:
	print(''.join(result))
else:
	print(-1)


n = int(input())
if n > 36:
	print('-1')
else:
	print('8' * (n // 2) + '6' * (n % 2))


from sys import stdin, stdout
import math

def isprime(num):
	for i in range(1, int(math.sqrt(num))):
		if num % i == 0:
			return False
	return True
x = int(stdin.readline())
if x > 36:
	stdout.write(str(-1))
else:
	val1 = x // 2
	val2 = x % 2
	stdout.write(val1 * '8' + val2 * '9')
	print()


import math
n = int(input())
if math.ceil(n / 2) < 19:
	while True:
		if n - 2 < 0:
			break
		else:
			print(8, end='')
			n -= 2
	while True:
		if n - 1 < 0:
			break
		else:
			print(4, end='')
			n -= 1
else:
	print(-1)


k = int(input())
if k > 18 * 2:
	print(-1)
else:
	print('8' * (k // 2) + '6' * (k % 2))


def main():
	n = int(input())
	print('4' * (n & 1) + '8' * (n // 2) if n < 37 else '-1')
main()


def main():
	k = int(input())
	if k == 1:
		print('4')
		return
	res = '8' * (k // 2)
	if k % 2 != 0:
		res += '0'
	print(res if len(res) <= 18 else -1)
main()


k = int(input())
if k > 36:
	print(-1)
else:
	output = ''
	for i in range(k // 2):
		output += '8'
	if k % 2 == 1:
		output += '4'
	print(output)


int_k = int(input())
if int_k % 2 == 1:
	k = '4'
	int_k -= 1
else:
	k = '8'
	int_k -= 2
while int_k > 0 and int(k) < 10 ** 18:
	k += '8'
	int_k -= 2
if int_k == 0 and int(k) < 10 ** 18:
	print(int(k))
else:
	print(-1)


k = int(input())
if k > 36:
	print(-1)
else:
	print('8' * (k // 2) + '9' * (k % 2))


loops = int(input())
eights = loops // 2
six = loops % 2
if loops > 36:
	print('-1')
else:
	for i in range(eights):
		print('8', end='')
	for i in range(six):
		print('6', end='')


n = int(input())
if n > 36:
	print('-1')
elif n <= 36 and n > 18:
	n -= 18
	for i in range(n):
		print('8', end='')
	for i in range(18 - n):
		print('6', end='')
elif n == 0:
	print('-1')
else:
	for i in range(n):
		print('6', end='')


k = int(input())
if k > 36:
	print('-1')
else:
	twoLoops = k // 2
	oneLoops = k % 2
	print('4' * oneLoops + '8' * twoLoops)


import sys

def printf(format, *args):
	sys.stdout.write(format % args)
k = int(input())
if k > 36:
	print('-1')
else:
	while k:
		if k >= 2:
			printf('%d', 8)
			k -= 2
		elif k == 1:
			printf('%d', 6)
			k = 0


a = int(input())
if a > 36:
	print(int(-1))
else:
	b = []
	while a != 0:
		if a % 2 == 0:
			b.append('8')
			a -= 2
		elif a % 2 == 1:
			b.append('6')
			a -= 1
	print(''.join(b))


n = int(input())
if n > 36:
	print(-1)
else:
	s = ''
	for j in range(n // 2):
		s = s + '8'
	if n % 2 != 0:
		s = s + '4'
	print(s)


k = int(input())
if k > 18 * 2:
	print(-1)
else:
	res = ''
	res += '8' * (k // 2)
	if k % 2:
		res += '9'
	print(res)


k = int(input())
if k > 36 or k < 0:
	print(-1)
elif k == 0:
	print(1)
else:
	a = 0
	while k > 1:
		a = a * 10 + 8
		k -= 2
	if k == 1:
		a = a * 10 + 6
	print(a)


k = int(input())
if k > 36:
	print('-1')
	quit()
r = k % 2
d = int(k / 2)
ans = ''
if r == 1:
	ans = '4'
ans += d * '8'
print(ans)


k = int(input())
if k > 36:
	print(-1)
else:
	for i in range(int(k / 2)):
		print(8, end='')
	if k % 2 != 0:
		print(4)


n = eval(input())
if n > 36:
	print('-1', end='')
else:
	for i in range(1, int(n / 2 + 1)):
		print('8', end='')
	if n % 2:
		print('6', end='')
print('\n')


n = int(input())
if n >= 37:
	s = -1
elif n % 2 == 0:
	s = '8' * (n // 2)
else:
	s = '8' * (n // 2) + '6'
print(s)


from sys import *
import random

def lot(k):
	a = [0, 4, 6, 9]
	b = [1, 3, 5, 7]
	if k > 36:
		return [-1]
	else:
		result = []
		while k > 1:
			result.append(8)
			k = k - 2
		if k == 1:
			i = random.randint(0, 3)
			n = a[i]
			result.append(n)
		if result[0] == 0:
			c = random.randint(0, 2)
			result[0] = a[c + 1]
		return result
k = int(input())
print(*lot(k), sep='')


n = int(input())
if n > 40:
	print(-1)
else:
	str = ''
	while n != 0:
		if n % 2 == 0:
			str += '8'
			n -= 2
		elif n % 2 == 1:
			str += '4'
			n -= 1
	if int(str) > 10 ** 18:
		print(-1)
	else:
		print(str)


a = int(input())
if a > 36:
	print(-1)
elif a % 2 == 0:
	a = a // 2
	print('8' * a)
else:
	a = a // 2
	c = '8' * a
	print(c + '6')


n = int(input())
if n > 36:
	print(-1)
else:
	print(*['8' * (n // 2) + '9' * (n % 2)])


import sys

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

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

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

def listinput():
	return list(map(int, input().split()))
n = iinput()
if n > 36:
	print(-1)
else:
	print('8' * (n // 2) + '4' * (n % 2))


k = int(input())
if k == 1:
	print(6)
	exit()
if k <= 36:
	if k % 2:
		print('8' * (k // 2) + '0')
	else:
		print('8' * (k // 2))
else:
	print(-1)


k = int(input())
x = k // 2 * '8'
if k % 2 == 1:
	x += '9'
if len(x) > 18:
	x = -1
print(x)


from collections import deque
from math import ceil, floor, sqrt, gcd

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

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

def li():
	return list(mi())

def si():
	return input()
n = ii()
if n > 36:
	print('-1')
else:
	x = n // 2
	y = n % 2
	print('8' * x + '6' * y)


k = int(input())
a = '8' * (k // 2) + '6' * (k % 2)
if len(a) > 18:
	print(-1)
	exit(0)
print(a)


k = int(input())
i = k
j = 0
a = [''] * 18
if k > 36:
	print(-1)
else:
	while i > 1:
		a[j] = '8'
		j += 1
		i -= 2
	if i == 1:
		a[j] = '4'
	print(''.join(a))


k = int(input())
if k > 36:
	print(-1)
else:
	eight = k // 2
	other = k % 2
	print('8' * eight + '9' * other)


k = int(input())
if k > 36 or k < 0:
	print(-1)
else:
	while k > 0:
		if 2 <= k:
			print(8, end='')
			k = k - 2
		else:
			print(4)
			k = k - 1


n = int(input())
if n > 36:
	print(-1)
else:
	a = []
	num1 = n // 2
	num2 = n - num1 * 2
	for i in range(num1):
		print('8', end='')
	for i in range(num2):
		print('4', end='')


t = int(input())
if t > 36:
	print('-1')
else:
	while t > 0:
		if t >= 2:
			print('8', sep='', end='')
			t -= 2
		elif t == 1:
			print('9', sep='', end='')
			t -= 1


k = int(input())
if k > 36:
	print(-1)
else:
	x = ''
	for i in range(k // 2):
		x += '8'
	if k % 2:
		x += '6'
	print(x)


n = int(input())
if n > 36:
	print(-1)
else:
	list = []
	while n > 0:
		if n >= 2:
			list.append('8')
			n -= 2
		elif n >= 1:
			list.append('4')
			n -= 1
		elif n == 1:
			list.append('0')
			n -= 1
		s = ''.join(list)
	print(s)


def calc(k):
	s = ''
	t = pow(10, 18)
	while k > 1:
		s += '8'
		if int(s) > t:
			return -1
		k -= 2
	if k == 0:
		return s
	else:
		s += '4'
		if int(s) > t:
			return -1
		return s
k = int(input())
print(calc(k))


n = int(input())
k = n // 2
l = n % 2
z = 0
p = -1
i = 0
j = 0
while i < k:
	z *= 10
	z += 8
	i = i + 1
	if z > 1000000000000000000:
		break
while j < l:
	z *= 10
	z += 4
	j = j + 1
if z > 1000000000000000000:
	print(p)
else:
	print(z)


n = int(input())
if n > 36:
	print(-1)
else:
	num = 0
	for i in range(n // 2):
		num = num * 10 + 8
	if n % 2 == 1:
		num = num * 10 + 6
	print(num)


k = int(input())
b = ''
if k > 36:
	print(-1)
else:
	while k > 0:
		if k >= 2:
			b += '8'
			k -= 2
		else:
			b += '4'
			k -= 1
print(b)


a = int(input())
if a > 36:
	print(-1)
else:
	print('8' * (a // 2) + '4' * (a % 2))


p = int(input())
print(['8' * (p // 2) + '9' * (p % 2), -1][p > 36])


def test_4():
	k = list(map(int, input().split(' ')))
	k = k[0]
	if k > 36:
		print('-1', end='')
	else:
		num1 = int(k / 2)
		num2 = int(k - num1 * 2)
		for i in range(num1):
			print('8', end='')
		for i in range(num2):
			print('4', end='')
	return 0
aa = test_4()


import sys
k = int(input())
if k > 36:
	print(-1)
	sys.exit()
if k == 0:
	print(1)
	sys.exit()
if k == 1:
	print(6)
	sys.exit()
for i in range(0, k // 2):
	print(8, end='')
if k % 2:
	print(0)


k = int(input())

def loop(k):
	if k > 36:
		return -1
	a = k // 2
	b = k % 2
	s = '8' * a
	s += '4' * b
	return int(s)
print(loop(k))


def solve():
	n = int(input())
	if n > 36:
		print(-1)
		return
	else:
		a = n // 2
		b = n % 2
	print('8' * a + '4' * b)
solve()


n = int(input())
if n > 18 * 2:
	print(-1)
else:
	s = ''
	while n >= 2:
		s += '8'
		n -= 2
	while n >= 1:
		s += '4'
		n -= 1
	print(s)


n = int(input())
if n > 36:
	print(-1)
elif n % 2 == 0:
	for i in range(int(n / 2)):
		print(8, end='')
elif n % 2 == 1:
	for i in range(int((n - 1) / 2)):
		print(8, end='')
	print(4)


n = int(input())
if n < 37:
	print('8' * (n // 2) + '9' * (n % 2))
else:
	print('-1')


K = int(input())
S1 = {0, 4, 6, 9}
S2 = {8}
if K == 1:
	print(4)
	exit()
if K > 36:
	print(-1)
else:
	d = (K + 1) // 2
	ans = '8' * (K - d) + '4' * (2 * d - K)
	print(ans)


k = int(input())
print('8' * (k // 2) + ('4' if k % 2 else '') if k <= 36 else -1)


n = int(input())
k = n // 2
k1 = n % 2
print('8' * k + '9' * k1 if n <= 36 else -1)


def loops(k):
	if k > 36:
		return -1
	else:
		(two, one, number) = ('8', '9', '')
		while k > 0:
			if k >= 2:
				number += two
				k = k - 2
			else:
				number += one
				k = k - 1
		return int(number)
k = int(input())
print(loops(k))


k = int(input())
if k < 37:
	if k % 2 == 0:
		print(int('8' * int(k / 2)))
	else:
		print(int('8' * (k // 2) + '6'))
else:
	print(-1)


import sys
f = sys.stdin
n = int(f.readline())
num_loop = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1]
if n > 300:
	n = 300
d = [[-1] * (n + 1) for _ in range(20)]
d[0][0] = -2
ans = -1
for i in range(18):
	if d[i][n] != -1:
		ans = i
		break
	for j in range(n):
		if d[i][j] == -1:
			continue
		for k in range(10):
			if j + num_loop[k] <= n:
				d[i + 1][j + num_loop[k]] = k
if d[18][n] != -1:
	ans = 18
if ans == -1:
	print(-1)
else:
	r = []
	tn = n
	while ans > 0:
		k = d[ans][tn]
		r.append(k)
		ans -= 1
		tn -= num_loop[k]
	print(''.join(map(str, r[::-1])))


import math
n = int(input())
s = ''
if n < math.pow(10, 6) and n / 2 < 18.5:
	if n == 1:
		s += '4'
	elif n % 2 == 0:
		for i in range(n // 2):
			s += '8'
	elif n // 2 != 0 and n != 1:
		for i in range(n // 2):
			s += '8'
		s += '4'
if len(s) > 0:
	print(s)
else:
	print(-1)


n = int(input())
if n > 36:
	print(-1)
else:
	s = ''
	for i in range(n // 2):
		s += '8'
	if n % 2 == 1:
		s += '4'
	print(s)


k = int(input())
if k > 18 * 2:
	print(-1)
else:
	ans = []
	while k > 1:
		ans.append('8')
		k -= 2
	if k == 1:
		ans.append('6')
	print(int(''.join(ans)))


n = int(input())
if n > 36:
	print(-1)
else:
	ans = ''
	if n == 1:
		ans = '6'
	elif n % 2 == 0:
		b = n // 2
		for i in range(b):
			ans += '8'
	else:
		b = (n - 1) // 2
		for i in range(b):
			ans += '8'
		ans += '0'
	print(int(ans))


pt = lambda *a, **k: print(*a, **k, flush=True)
k = int(input())
if k > 36:
	pt(-1)
else:
	while k:
		if k & 1:
			pt('4', end='')
			k -= 1
		else:
			pt('8', end='')
			k -= 2


k = int(input())
if k > 50:
	print(-1)
	exit(0)
x = '4' * (k % 2) + '8' * (k // 2)
if int(x) <= int(1e+18):
	print(x)
else:
	print(-1)


(x, y) = divmod(int(input()), 2)
print(-1 if 2 * x + y > 36 else '8' * x + '4' * y)


n = int(input())
if n > 36:
	print(-1)
elif n == 1:
	print(4)
else:
	f = ''
	e = n // 2
	f = '8' * e
	if n % 2 == 0:
		pass
	else:
		f = f + '4'
	print(f)


n = int(input())
if n == 1:
	print(4)
else:
	ans = 0
	valid = True
	while n - 2 >= 0:
		ans *= 10
		ans += 8
		n -= 2
		if ans > 10 ** 18:
			valid = False
			break
	while n - 1 >= 0:
		ans *= 10
		ans += 0
		n -= 1
		if ans > 10 ** 18:
			valid = False
			break
	if not valid:
		print(-1)
	else:
		print(ans)


k = int(input())
if k > 36:
	print('-1')
	quit()
if k % 2 == 1:
	print('4', end='')
for i in range(1, k // 2 + 1):
	print('8', end='')


import sys
k = int(sys.stdin.readline())
if k > 36:
	print('-1')
else:
	while k > 1:
		print('8', end='')
		k -= 2
	if k != 0:
		print('9')


n = int(input())
maxx = 2 * 18
if n > maxx:
	print(-1)
else:
	eight = n // 2
	ans = '8' * eight
	if n % 2:
		ans += '4'
	print(ans)


n = int(input())
str = ''
if n > 36:
	print(-1)
else:
	for _ in range(n // 2):
		str += '8'
	if n % 2:
		str += '9'
	print(str)


def build(n):
	return '8' * (n // 2) + '9' * (n % 2)
ins = int(input())
print([build(ins), -1][ins > 36])


import math
n = int(input())
m = n // 2
cnt = 1
if n > 36:
	print(-1)
else:
	for i in range(m):
		print('8', end='')
	if n % 2 > 0:
		print('6')


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping

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

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

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

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 get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
k = int(input())
if k % 2:
	if k // 2 + 1 > 18:
		print(-1)
	else:
		print('8' * (k // 2) + '4')
else:
	temp = k // 2
	if temp > 18:
		print(-1)
	else:
		print('8' * temp)


n = int(input())
k = n // 2
s = 0
if n % 2 == 1:
	s += 1
s += k
if s > 18:
	print(-1)
else:
	print('4' * (n % 2) + '8' * k)


k = int(input())
now = 0
ans = ''
if k >= 38:
	print(-1)
elif k == 1:
	print(4)
else:
	while True:
		if k - now >= 2:
			now += 2
			ans += '8'
		elif k - now == 1:
			ans += '0'
			now += 1
		elif k - now == 0:
			break
	if int(ans) <= 10 ** 18:
		print(ans)
	else:
		print(-1)


n = int(input())
li = []
while n > 1:
	li.append('8')
	n -= 2
	if len(li) > 18:
		print('-1')
		exit()
if n == 1:
	li.append('6')
	if len(li) > 18:
		print('-1')
		exit()
print(''.join(li))


k = int(input())
if k > 36:
	print(-1)
else:
	eights = k // 2
	zeros = k % 2
	print('8' * eights + '4' * zeros)


k = int(input())
if k > 36:
	print(-1)
else:
	ans = ''
	while k:
		if k >= 2:
			k -= 2
			ans += '8'
		elif k == 1:
			k -= 1
			ans += '9'
	print(ans)


k = int(input())
if k / 2 > 18:
	print(-1)
else:
	for i in range(k // 2):
		print('8', end='')
	if k % 2:
		print('6', end='')


k = int(input())
if k > 36:
	print(-1)
else:
	for i in range(k // 2):
		print(8, end='')
	for i in range(k % 2):
		print(9, end='')


g = ['6', '8', '2']
k = int(input())
if k > 18 * 2:
	print(-1)
else:
	print(g[1] * (k // 2), end='')
	print(g[0] * (k % 2), end='')


n = int(input())
if n == 1:
	print('9')
elif n == 2:
	print('99')
elif n == 3:
	print('999')
elif n == 4:
	print('9999')
elif n == 5:
	print('99999')
elif n == 6:
	print('999999')
elif n == 7:
	print('8880')
elif n == 8:
	print('8888')
elif n == 9:
	print('88880')
elif n == 10:
	print('88888')
elif n == 11:
	print('888880')
elif n == 12:
	print('888888')
elif n == 13:
	print('8888880')
elif n == 14:
	print('8888888')
elif n == 15:
	print('88888880')
elif n == 16:
	print('88888888')
elif n == 17:
	print('888888880')
elif n == 18:
	print('888888888')
elif n == 19:
	print('8888888880')
elif n == 20:
	print('8888888888')
elif n == 21:
	print('88888888880')
elif n == 22:
	print('88888888888')
elif n == 23:
	print('888888888880')
elif n == 24:
	print('888888888888')
elif n == 25:
	print('8888888888880')
elif n == 26:
	print('8888888888888')
elif n == 27:
	print('88888888888880')
elif n == 28:
	print('88888888888888')
elif n == 29:
	print('888888888888880')
elif n == 30:
	print('888888888888888')
elif n == 31:
	print('8888888888888880')
elif n == 32:
	print('8888888888888888')
elif n == 33:
	print('88888888888888880')
elif n == 34:
	print('88888888888888888')
elif n == 35:
	print('888888888888888880')
elif n == 36:
	print('888888888888888888')
else:
	print('-1')


k = int(input())
s = ''
while k > 0:
	if k > 1:
		s = s + '8'
		k = k - 2
	else:
		s = s + '4'
		k = k - 1
if len(s) < 19:
	print(s)
else:
	print(-1)


k = int(input())
if k <= 40:
	a = k % 2
	b = k // 2
	print
	if int(str(8) * b + str(4) * a) < 10 ** 18:
		print(str(8) * b + str(4) * a)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
if n > 36:
	print(-1)
else:
	ans = []
	i = 0
	while n >= 2:
		ans.append('8')
		n -= 2
	if n == 1:
		ans.append('4')
		n -= 1
	x = ''.join(ans)
	print(int(x))


x = int(input())
if x > 36:
	print(-1)
	exit()
print('8' * (x // 2) + '6' * (x % 2))


k = int(input())
result = []
if k > 36:
	print(-1)
else:
	while k > 0:
		result.append(8 if k % 2 == 0 else 4)
		k -= 2 if k % 2 == 0 else 1
print(''.join(map(str, result)))


n = int(input())
if n > 36:
	print(-1)
else:
	a = '8' * (n // 2)
	if n % 2 != 0:
		a += '4'
	print(a)


n = int(input())
s = ('4' if n % 2 else '') + '8' * (n // 2)
if len(s) >= 20 or int(s) > 10 ** 18:
	print(-1)
else:
	print(s)


def main():
	k = int(input())
	if k > 36:
		print(-1)
		return
	num = ''
	for i in range(k // 2):
		num += str(8)
	if k % 2 != 0:
		num += '4'
	print(num)
main()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 15
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	if n > 36:
		return -1
	if n == 0:
		return 1
	s = ''
	while n > 0:
		if n > 1:
			s += '8'
			n -= 2
		else:
			s += '4'
			n -= 1
	return s
print(main())


n = int(input())
if n == 1:
	print(4)
elif n > 36:
	print(-1)
else:
	s = []
	temp = n
	while True:
		if temp >= 2:
			s.append('8')
			temp -= 2
			if temp == 0:
				break
		elif temp == 1:
			s.append('4')
			temp -= 1
			break
		elif temp == 0:
			break
	print(int(''.join(s)))


n = int(input())
if n > 40:
	print(-1)
else:
	x = '4' * (n % 2) + '8' * (n // 2)
	if int(x) < 10 ** 18:
		print(x)
	else:
		print(-1)


k = int(input())
a = ''
if k > 36:
	print(-1)
	exit()
if k & 1:
	a = a + k // 2 * '8'
	a += '4'
else:
	a = k // 2 * '8'
print(a)


n = int(input())
if n == 0:
	print('1')
elif n // 2 + n % 2 < 19:
	print('8' * (n // 2) + '4' * (n % 2))
else:
	print(-1)


n = int(input())
out = ''
if n > 36:
	print(-1)
else:
	for i in range(n // 2):
		out += '8'
	for i in range(n % 2):
		out += '9'
	if n == 0:
		out += '1'
	print(out)


n = int(input())
if n > 36:
	print(-1)
else:
	ans = ''
	while n:
		if n % 2 == 1:
			ans = '9'
			n -= 1
		else:
			ans += '8'
			n -= 2
	print(ans)


import math
import sys
input = sys.stdin.readline

def main():
	n = int(input())
	if n > 36:
		print(-1)
	else:
		print('8' * (n // 2), end='')
		if n % 2 == 1:
			print('4')
main()


a = int(input())
print(-1 if a > 36 else '8' * (a // 2) + '6' * (a % 2))


a = int(input())
if a < 38:
	c = a % 2
	d = ('4' if c else '') + '8' * (a // 2)
	k = d if int(d) <= 10 ** 18 else -1
	print(k)
else:
	print(-1)


k = int(input())
loops = {0: 1, 1: 0, 2: 0, 3: 0, 4: 1, 5: 0, 6: 1, 7: 0, 8: 2, 9: 1}
if k > 36:
	print(-1)
else:
	ans = ''
	ans += '8' * (k // 2)
	ans += '4' * (k % 2)
	print(ans)


class Solution:

	def resolve(self, k):
		if k > 18 * 2:
			return -1
		else:
			re = []
			while k > 1:
				re.append('8')
				k -= 2
			if k > 0:
				re.append('4')
			return ''.join(re)
s = Solution()
k = int(input())
re = s.resolve(k)
print(re)


n = int(input())
if n > 36:
	print(-1)
else:
	result = ''
	loops = 0
	while loops < n:
		if loops + 1 == n:
			result += '4'
			loops += 1
		else:
			result += '8'
			loops += 2
	print(result)


k = int(input())
r = '8' * (k // 2) + ('4' if k % 2 == 1 else '')
if len(r) > 19 or int(r) > 1000000000000000000:
	r = -1
elif len(r) == 0:
	r = '1'
print(r)


def big(n):
	s = ''
	if n == 1:
		return 6
	if n > 36:
		return -1
	while n > 1:
		s += '8'
		n -= 2
	if n == 1:
		s += '0'
	return s
print(big(int(input())))


k = int(input())
if k >= 37:
	print(-1)
else:
	print('8' * (k // 2) + '4' * (k % 2))


k = int(input())
ans = '4' * (k % 2) + '8' * (k // 2)
if len(ans) < 19:
	print(ans)
else:
	print(-1)


n = int(input())
if n > 18 * 2:
	print(-1)
else:
	s = ''
	while n > 0:
		if n >= 2:
			s = s + '8'
			n -= 2
		else:
			s = s + '9'
			n -= 1
	print(s)


k = int(input())
s = ''
if k >= 40:
	print(-1)
else:
	while k >= 2:
		s += '8'
		k -= 2
	if k:
		s += '4'
	if int(s) > 10 ** 18:
		print(-1)
	else:
		print(s)


n = int(input())
m = 10 ** 18
if n > 100:
	print(-1)
else:
	ans = '8' * (n // 2) + ('6' if n % 2 == 1 else '')
	if int(ans) < m:
		print(ans)
	else:
		print(-1)


n = int(input())
l = list()
if n > 36:
	print(-1)
else:
	for i in range(n // 2):
		l.append(8)
	if n % 2 == 1:
		l.append(4)
	print(*l, sep='')


def main():
	k = int(input())
	if k == 0:
		print(1)
	else:
		s = ''
		while k > 0:
			if k >= 2:
				s += '8'
				k -= 2
			else:
				s += '4'
				k -= 1
			if len(s) >= 19:
				s = '-1'
				break
		print(s)
main()


k = int(input())
if k > 36:
	print(-1)
else:
	res = '8' * (k // 2)
	if k % 2 != 0:
		res = res + '9'
	print(res)


k = int(input())
if k > 40:
	print(-1)
else:
	ans = 0
	while k >= 2:
		ans *= 10
		ans += 8
		k -= 2
	if k == 1:
		if ans > 0:
			ans *= 10
		else:
			ans = 4
	if ans <= 1000000000000000000:
		print(ans)
	else:
		print(-1)


n = int(input())
s = ''
if n // 2 + n % 2 > 18:
	print(-1)
else:
	for i in range(n // 2):
		print(8, end='')
	for i in range(n % 2):
		print(4)


m = int(input())
s = ''
if m > 36:
	print(-1)
elif m <= 18:
	for x in range(m):
		s = s + '4'
	print(int(s))
else:
	a = 36 - m
	for x in range(a):
		s = s + '4'
	a = 18 - a
	for x in range(a):
		s = s + '8'
	print(int(s))


n = int(input())
if n >= 10 ** 6 or n / 2 > 18:
	print('-1')
elif n % 2 == 1 and n < 10 ** 6:
	num = n // 2
	print('8' * num + '4')
else:
	num = n // 2
	print('8' * num)


k = int(input())
s = 0
if k % 2 == 1:
	s = 4
	k -= 1
while k > 0:
	k -= 2
	s = s * 10 + 8
	if s > 1000000000000000000:
		s = -1
		k = 0
print(s)


k = int(input())
if k > 36:
	print(-1)
elif k == 1:
	print(4)
elif k % 2 == 0:
	s = '8' * (k // 2)
	if len(s) > 10 ** 18:
		print(-1)
	else:
		print('8' * (k // 2))
else:
	s = '8' * (k // 2) + '4'
	if len(s) > 10 ** 18:
		print(-1)
	else:
		print('8' * (k // 2) + '4')


k = int(input())
if k > 36:
	print(-1)
else:
	v = k // 2
	n = k % 2
	print(v * '8' + n * '6')


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
loop = [8, 0, 4, 6, 9, 1, 2, 3, 5, 7]
if not n & 1:
	eight = n // 2
	if eight > 18:
		print(-1)
	else:
		print('8' * eight)
else:
	eight = n // 2
	if eight > 17:
		print(-1)
	else:
		print('8' * eight + '4')


def CF934B():
	k = int(input(''))
	if k > 36:
		print(-1)
	else:
		while k >= 2:
			print(8, end='')
			k -= 2
		if k == 1:
			print('4')
CF934B()


class CodeforcesTask934BSolution:

	def __init__(self):
		self.result = ''
		self.k = 0

	def read_input(self):
		self.k = int(input())

	def process_task(self):
		if self.k > 36:
			res = -1
		else:
			res = []
			while self.k:
				if self.k >= 2:
					res.append(8)
					self.k -= 2
				else:
					res.append(4)
					self.k -= 1
			res = int(''.join([str(x) for x in res]))
		self.result = str(res)

	def get_result(self):
		return self.result
Solution = CodeforcesTask934BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


k = int(input())
numb = '6' * (k % 2) + '8' * (k // 2)
print(numb if len(numb) < 19 else -1)


import sys
nb = int(sys.stdin.readline())
res = str()
if nb > 36:
	print(-1)
else:
	while nb >= 2:
		res += '8'
		nb -= 2
	if nb == 1:
		res += '4'
	print(res)


def pro(n):
	s = 0
	if n > 36:
		return -1
	else:
		while n > 0:
			if n % 2 == 0 or n > 2:
				s = s * 10 + 8
				n = n - 2
			else:
				s = s * 10 + 4
				n = n - 1
	return s
num = int(input())
print(pro(num))


n = int(input())
flag = True
s = ''
while n > 0:
	if n >= 2:
		s += '8'
		n -= 2
	elif n == 1:
		s += '4'
		n -= 1
	if len(s) > 18:
		print(-1)
		flag = False
		break
if flag:
	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')

def main():
	pass

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

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	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]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

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

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

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
k = iinp()
if k > 36:
	print(-1)
elif k == 1:
	print(9)
else:
	ans = [8] * (k // 2)
	if k % 2 == 1:
		ans.append(0)
	print(lts(ans))


a = int(input())
if a > 37:
	print(-1)
elif a == 1:
	print('4')
else:
	s = ''
	if a % 2 == 0:
		for i in range(0, a, 2):
			s += '8'
		if len(s) > 18:
			print(-1)
		else:
			print(s)
	else:
		for i in range(0, a - 1, 2):
			s += '8'
		s += '0'
		if len(s) > 18:
			print(-1)
		else:
			print(s)


a = int(input())
l = list()
if a <= 36:
	for x in range(a // 2):
		l.append('8')
	for x in range(a % 2):
		l.append('4')
	print(''.join(l))
else:
	print('-1')


import math
n = int(input())
if n > 36:
	print(-1)
else:
	s = '8' * math.floor(n / 2)
	if n % 2 == 1:
		s += '6'
	print(s)


k = int(input())
if k % 2 == 0 and k <= 36:
	for i in range(k // 2):
		print('8', end='')
elif k % 2 != 0 and k < 36:
	for i in range(k // 2):
		print('8', end='')
	print('9')
else:
	print('-1')


k = int(input())
if k < pow(10, 6):
	if k % 2 == 0:
		if int('8' * (k // 2)) < pow(10, 18):
			print(int('8' * (k // 2)))
		else:
			print('-1')
	elif int('8' * (k // 2) + '4') < pow(10, 18):
		print(int('8' * (k // 2) + '4'))
	else:
		print('-1')
else:
	print('-1')


a = int(input())
if a == 1:
	print(4)
elif a == 0:
	print(1)
elif a <= 18 * 2:
	n = int(a / 2) - 1
	num = 8
	while n > 0:
		num = num * 10 + 8
		n -= 1
	if a % 2 == 1:
		num = num * 10 + 4
	print(num)
else:
	print(-1)


k = int(input())
a = ''
if k > 36:
	print(-1)
	quit()
if k % 2 == 0:
	a = a + '8' * (k // 2)
else:
	a = a + '8' * (k // 2) + '6'
print(int(a))


pet = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1]
n = 0
k = int(input())
while k >= 2:
	n = n * 10 + 8
	if n > 1e+18:
		break
	k -= 2
if k == 1:
	n = n * 10 + 9
if n > 1e+18:
	print(-1)
else:
	print(n)


n = int(input())
print([-1, int(n / 2) * '8' + n % 2 * '4'][n <= 36])


k = int(input())
if k <= 18 * 2:
	e = k // 2
	z = k % 2
	print('8' * e + z * '6')
elif k == 0:
	print(1)
else:
	print(-1)


k = int(input())
getalarray = []
while k > 0:
	if k % 2 == 0:
		num = int(k / 2)
		getalarray.append('8')
		k = int(k - 2)
	elif k % 1 == 0:
		getalarray.append('6')
		k = int(k - 1)
getal = ''
getalarray.reverse()
if len(getalarray) > 18:
	print('-1')
else:
	for i in getalarray:
		getal += i
	print(getal)


n = int(input())
if n == 0:
	print('1')
elif n > 36:
	print(-1)
else:
	ans = '8' * (n // 2)
	if n % 2 == 1:
		ans += '9'
	print(ans)


ones = [6, 9]
two = [8]
k = int(input())
answer = ''
val = 0
while k > 0 and val < int(pow(10, 18)):
	if k >= 2:
		answer += str(two[0])
		k -= 2
	else:
		answer += str(ones[0])
		k -= 1
	val = int(answer)
if val >= int(pow(10, 18)):
	answer = -1
print(answer)


k = int(input())
print(-1 if k > 36 else ''.join([str(x) for x in k // 2 * [8] + (k & 1) * [4]]))


k = int(input())
if k > 36:
	print(-1)
else:
	a = k // 2
	b = k % 2
	s = '8' * a + '9' * b
	print(s)


n = int(input())
s = 0
if n > 36:
	print('-1')
else:
	while n > 0:
		if n % 2 == 0 or n > 2:
			s = s * 10 + 8
			n = n - 2
		else:
			s = s * 10 + 4
			n = n - 1
	print(s)


k = int(input())
if k > 36:
	print(-1)
else:
	res = 0
	while k > 0:
		if k >= 2:
			res = res * 10 + 8
			k -= 2
		else:
			res = res * 10 + 6
			k -= 1
	print(res)


x = int(input())
print(['8' * (x // 2) + '4' * (x % 2), -1][x > 36])


k = eval(input())
ans = ''
for i in range(k // 2):
	ans = ans + '8'
if k % 2 == 1:
	ans = ans + '4'
if k <= 36:
	print(ans)
else:
	print('-1')


def main():
	K = int(input())
	if K > 36:
		print(-1)
		return
	(div_, mod_) = divmod(K, 2)
	n = '8' * div_
	if mod_:
		n = n + '9'
	print(n)
main()


import math
import sys
from collections import *
import itertools

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

def cstr():
	return list(map(str, input().split(' ')))

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

def solve(t):
	n = int(input())
	if n == 0:
		print(5)
	elif n > 36:
		print(-1)
	elif n % 2 == 0:
		ans = '8' * (n // 2)
		print(int(ans))
	else:
		ans = '4' + '8' * (n // 2)
		print(int(ans))
t = 1
for i in range(1, t + 1):
	solve(i)


num = int(input())

def prosperous(n):
	if n > 36:
		return '-1'
	s = ''
	if n == 0:
		return '1'
	while n > 1:
		s += '8'
		n -= 2
	if n == 1:
		s += '4'
		n -= 1
	if n == 0:
		return s
print(prosperous(num))


p = int(input())
print('8' * (p // 2) + '9' * (p % 2) if p <= 36 else -1)


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
n = int(input())
if n > 36:
	print(-1)
	exit()
a = n // 2
b = n % 2
ans = '8' * a + '4' * b
print(ans)


import sys
k = int(input())
if k // 2 + k % 2 > 18:
	print(-1)
	sys.exit()
if k % 2 == 0:
	print('8' * (k // 2))
else:
	print('4', '8' * (k // 2), sep='')


k = int(input())
if 2 * 18 < k:
	print(-1)
else:
	a = '8' * (k // 2) + '9' * (k % 2)
	print(a)


D = {0: 1, 1: 0, 2: 0, 3: 0, 4: 1, 5: 0, 6: 1, 7: 0, 8: 2, 9: 1}
k = int(input())
s = '-1'
if k <= 36:
	if k % 2 == 0 and k > 0:
		s = k // 2 * '8'
		if int(s) > 10 ** 18:
			s = '-1'
	elif k == 0:
		s = '1'
	else:
		s = k // 2 * '8'
		s = '4' + s
		if int(s) > 10 ** 18:
			s = '-1'
print(s)


import sys

def read_problem():
	ll = []
	while True:
		l = sys.stdin.readline()
		if l == '':
			break
		else:
			ll.append(l)
	p = int(ll[0].strip())
	return p

def write_solution(s):
	print(s)

def solve(p):
	petli = {0: 1, 1: 0, 2: 0, 3: 0, 4: 1, 5: 0, 6: 1, 7: 0, 8: 2, 9: 1}
	if p > 18 * 2:
		s = -1
	elif p == 1:
		s = 4
	else:
		(p_mod, p_rem) = (p // 2, p % 2)
		s = [8] * p_mod
		if p_rem:
			s.append(0)
		s = ''.join([str(e) for e in s])
	return s
problem = read_problem()
solution = solve(problem)
write_solution(solution)


from sys import stdin, stdout
k = int(stdin.readline())
if k > 36:
	stdout.write('-1')
else:
	ans = '8' * (k // 2)
	if k & 1:
		ans += '6'
	stdout.write(ans)


import math
k = int(input())
if k > 36:
	print(-1)
else:
	for i in range(k // 2):
		print(8, end='')
	if k % 2 != 0:
		print(9, end='')
print('')


k = int(input())
ans = ''
if k >= 37:
	print(-1)
	exit(0)
elif k % 2 == 0:
	ans += '8' * (k // 2)
else:
	ans += '8' * (k // 2)
	ans += '4'
print(ans)


from sys import exit
loops = [1, 4, 8]
n = int(input())
s = []
while n > 0:
	k = min(2, n)
	s.append(loops[k])
	n -= k
	if len(s) > 18:
		print('-1')
		exit(0)
if not s:
	s = [1]
print(''.join(map(str, s)))


t = int(input())
s = t // 2 * '8' + t % 2 * '4'
if len(s) <= 18:
	print(s)
else:
	print(-1)


n = int(input())
if n > 36:
	print(-1)
	exit()
if n % 2 == 0:
	for i in range(n // 2):
		print(8, end='')
else:
	for i in range(n // 2):
		print(8, end='')
	print(4, end='')


def func(k):
	if k > 36:
		return -1
	ans = ''
	while k > 1:
		ans += '8'
		k -= 2
	if k != 0:
		ans += '6'
	return int(ans)
n = int(input())
print(func(n))


def strp(s):
	for m in s:
		print(m, end='')
loop = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1]
k = int(input())
s = []
if k == 1:
	s.append('4')
else:
	for i in range(k // 2):
		s.append('8')
	if k % 2 == 1:
		s.append('0')
if len(s) <= 18:
	strp(s)
else:
	print(-1)


t = int(input())
if t > 36:
	print(-1)
else:
	a8 = t // 2
	a0 = t % 2
	print('8' * a8 + '4' * a0)


def main():
	k = int(input())
	num = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1]
	if k > 18 * 2:
		print(-1)
		return
	if k == 1:
		print(9)
		return
	ans = []
	while k:
		if k >= 2:
			ans.append(8)
			k -= 2
		else:
			ans.append(0)
			k -= 1
	print(''.join(map(str, ans)))
main()


k = int(input())
if (k + 1) // 2 > 18:
	print('-1')
elif k % 2 == 0:
	print('8' * (k // 2))
else:
	print('8' * (k // 2), end='')
	print('4')


n = int(input())
z = n // 2
s = '8' * z
if n % 2 == 0:
	s = s
else:
	s = s + '6'
if n > 36:
	print(-1)
else:
	print(s)


n = int(input())
if n > 50:
	print('-1')
else:
	s = '8' * (n // 2) + '6' * (n % 2)
	if int(s) < 10 ** 18:
		print(s)
	else:
		print('-1')


a = int(input())
t = 0
if a % 2 == 0:
	b = 8
	for k in range(int(a / 2 - 1)):
		b = b * 10 + 8
		if b > 10 ** 18:
			print(-1)
			t = 1
			break
else:
	b = 4
	for k in range(int(a / 2)):
		b = b * 10 + 8
		if b > 10 ** 18:
			print(-1)
			t = 1
			break
if t != 1:
	print(b)


from sys import exit
k = int(input())
inf = 10 ** 18
if k == 1:
	print(4)
	exit(0)
v = 8
k -= 2
while k > 1:
	v *= 10
	v += 8
	k -= 2
	if v > inf:
		break
if k:
	v *= 10
print(v if v <= inf else -1)


k = int(input())
ans = ''
if k > 36:
	print(-1)
else:
	t = int(k / 2)
	ans = ans + t * '8'
	t = int(k % 2)
	ans = ans + t * '4'
	print(int(ans))


k = int(input())
if k == 1:
	print(6)
else:
	x = k // 2
	y = k % 2
	ans = ''
	if x + y > 18:
		print(-1)
	else:
		for i in range(x):
			ans += '8'
		for i in range(y):
			ans += '0'
		if int(ans) > 1e+18:
			print(-1)
		else:
			print(ans)


k = int(input())

def first(k):
	a = k // 2
	b = k % 2
	n = int(str(8) * a + str(6) * b)
	return n

def second(k):
	a = k - 16
	n = int(str(0) * a + str(8) * 8)
	if n <= 10 ** 18:
		return n
	else:
		return -1
if k <= 36:
	print(first(k))
else:
	print(-1)


a = int(input())
if a > 36:
	print(-1)
else:
	s = ''
	b = 1
	c = a // 2
	while b <= c:
		s += '8'
		b = b + 1
	if a % 2 == 1:
		s += '9'
	print(s)


n = int(input())
if n > 36:
	print(-1)
	exit()
for i in range(n // 2):
	print(8, end='')
if n % 2 == 1:
	print(6, end='')


n = int(input())
if n > 36:
	print('-1')
	exit(0)
print('8' * (n // 2), end='')
print('6' * (n % 2))


n = int(input())
str = ''
if n > 36:
	print(-1)
else:
	y = int(n / 2)
	r = n % 2
	str = '8' * y
	if r == 1:
		str += '6'
	print(str)


n = int(input())
str = '8' * (n // 2) + '4' * (n % 2)
if len(str) > 18:
	print(-1)
else:
	print(str)


k = int(input())
m = k // 2 + k % 2
res = ''
if m > 18:
	print(-1)
else:
	for i in range(k // 2):
		res += '8'
	if k % 2 == 1:
		res += '4'
	print(res)


from sys import *
import random
n = int(input())

def check(n):
	a = 0
	if n <= 0 or n > 36:
		print(-1)
	elif n <= 18:
		a = 1 * random.choice([4, 6, 9])
		for i in range(n - 1):
			a = a * 10 + random.choice([4, 6, 9])
		print(a)
	elif n % 2 == 0:
		a = 8
		for i in range(n // 2 - 1):
			a = a * 10 + 8
		print(a)
	else:
		a = 9
		for i in range(n // 2):
			a = a * 10 + 8
		print(a)
check(n)


k = int(input())
if k > 36:
	print('-1')
elif k % 2 == 0:
	ls = ['8'] * int(k / 2)
	print(''.join(ls))
else:
	ls = ['8'] * int(k / 2) + ['6']
	print(''.join(ls))


def main():
	n = int(input())
	if n > 36:
		print(-1)
		return
	else:
		result = 0
		if n % 2 == 0:
			while n > 0:
				result = result * 10 + 8
				n -= 2
			print(result)
		else:
			while n > 1:
				result = result * 10 + 8
				n -= 2
			print(result * 10 + 4)
main()


def main():
	k = int(input())
	st = ''
	while len(st) <= 18:
		if k >= 2:
			st = st + str(8)
			k = k - 2
		elif k == 1:
			st = st + str(4)
			k = k - 1
		elif k == 0:
			break
	if k > 0 or len(st) > 18:
		print('-1')
	else:
		print(st)
main()


def solve(n):
	if n == 1:
		return '4'
	elif n == 2:
		return '8'
	else:
		return '8' + solve(n - 2)
n = int(input())
if n > 36:
	print(-1)
else:
	print(solve(n))


import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
k = int(input())
if k <= 18:
	print('4' * k)
elif k <= 36:
	a = k - 18
	b = 18 - a
	print('8' * a + '4' * b)
else:
	print(-1)


k = int(input())
s = ''
d = {9: 1, 8: 2}
if k > 36:
	print(-1)
else:
	for i in range(k // 2):
		s += '8'
	for i in range(k % 2):
		s += '9'
	if int(s) > 10 ** 18:
		print(-1)
	print(s)


n = int(input())
s = ''
while n > 0:
	if n >= 2:
		s += '8'
		n -= 2
	elif n == 1:
		s += '6'
		n -= 1
if len(s) > 18:
	print(-1)
else:
	print(s)


from sys import stdin
from math import floor

def get_ints():
	return list(map(int, stdin.readline().strip().split()))
k = int(input())
if k > 36:
	print(-1)
	exit()
n = '8' * (k // 2) if k % 2 == 0 else '8' * floor(k / 2) + '4'
if int(n) > 10 ** 18:
	print(-1)
else:
	print(n)


mx = 18 * 2
k = int(input())
ans = ''
if k > mx:
	print(-1)
else:
	while k:
		if k > 1:
			k -= 2
			ans += '8'
		elif k == 1:
			k -= 1
			ans += '6'
	if ans == '':
		ans += '1'
	print(ans)


a = {'0': 1, '1': 0, '2': 0, '3': 0, '4': 1, '5': 0, '6': 1, '7': 0, '8': 2, '9': 1}
k = int(input())
if k > 36:
	print('-1')
else:
	q = k // 2
	k = k % 2
	print('8' * q + k * '4')


number = int(input())
sum = 0
if number > 36:
	sum = -1
elif number == 1:
	sum = 4
else:
	for x in range(0, number // 2):
		sum = sum * 10 + 8
	if number % 2 != 0:
		sum = sum * 10
print(sum)


n = int(input().strip())
res = list()
while n > 0:
	if n >= 2:
		res.append(8)
		n -= 2
	elif n == 1:
		res.append(6)
		n -= 1
if len(res) > 18:
	print('-1')
else:
	print(''.join(map(str, res)))


loops = int(input())
if loops > 36:
	print(-1)
else:
	res = 0
	while loops >= 2:
		res = res * 10 + 8
		loops -= 2
	if loops == 1:
		res = res * 10 + 9
	print(res)