Birthday Numbers I

Find the numerically smallest number made only of digits 3, 5 and 8 whose digits add up to N, or -1 when none exists.

Medium4GreedyMathNo attempts yetTime limit1sMemory limit256 MB

Problem

Seunghyun was born on 5 March 1998, so he likes the digits 3, 5 and 8 that appear in his date of birth. He decided to call a positive integer a birthday number when its decimal representation consists only of the digits 3, 5 and 8. For example 3, 533 and 858553 are birthday numbers, while 3518, 1642 and 88808 are not.

Given a positive integer NN, find the smallest birthday number whose digits sum to NN.

Input

The first line contains the number of test cases TT (1T1001 \le T \le 100). Each of the next TT lines contains one positive integer NN (1N10000001 \le N \le 1\,000\,000).

Output

For each test case, print on its own line the smallest birthday number whose digits sum to NN. If no such number exists, print -1.