Find the smallest positive integer whose digit sum is exactly and whose decimal representation uses only lucky digits.
Given an integer , construct the smallest positive integer whose digits are all lucky digits and whose sum of digits is exactly .
In this problem, lucky digits are treated as the digits 4 and 7.
If no such integer exists, output -1.
The answer should be the numerically smallest possible among all valid numbers.
A single integer .
Print the smallest valid lucky-digit number whose digit sum is , or -1 if it does not exist.
Assume is a non-negative integer that fits in a standard 32-bit signed integer.
Example 1
Input
11
Output
47
Explanation
The digit sum is , and 47 is smaller than 74.
Example 2
Input
8
Output
44
Explanation
Two lucky digits sum to 8.
Example 3
Input
5
Output
-1
Explanation
No combination of digits 4 and 7 can produce a sum of 5.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.