Birthday Numbers I
Time limit1sMemory limit256 MB
Find the numerically smallest number made only of digits 3, 5 and 8 whose digits add up to N, or -1 when none exists.
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 , find the smallest birthday number whose digits sum to .
Input
The first line contains the number of test cases (). Each of the next lines contains one positive integer ().
Output
For each test case, print on its own line the smallest birthday number whose digits sum to . If no such number exists, print -1.