Stark vs Iron Monger

5

1 votes
Medium
Problem

Tony Stark suspects his archenemy Obadiah Stane (The Iron Monger) is once again plotting something diabolical. Tony’s companion, Jarvis, suggests Obadiah may be responsible for Friday’s recent issues with her functionalities.

Shortly after investigating, Tony receives a call from Obadiah boasting about infecting Friday with a virus. He also gives him a clue: an integer. Tony determines the key to removing the virus is to find the largest Decent Number having that number of digits.

A Decent Number has the following properties: Its digits can only be 3's and/or 5's. The number of 3's it contains is divisible by 5. The number of 5's it contains is divisible by 3. It is the largest such number for its length. Obadiah's virus shows a clock counting down to Friday's destruction, and time is running out fast. Your task is to help Tony find the key before Friday is destroyed!

Function Description: It should print the decent number for the given length, and if a decent number of that length cannot be formed print ‘-1’.

Input
The first line consists of an integer T denoting the number of test cases then the following line contains T integers N, each representing the number of digits in the Decent Number.

Output

Print the DecentNumbers for each query, separated by a new line.

Constraints

  • 0 < T < 100.

  • 1 << 200.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For n=7, which cannot be divided in terms of 5 and/or 3 (so we print ‘-1’). For n=14, which can be divided in terms of 5 and 3 which also follows Decent Number’s property.

Editor Image

?