Time limit
2s
Memory limit
128 MB
Eunmin likes the digits 4 and 7, and dislikes every other digit. A lucky number is a positive integer written using only the digits 4 and 7.
Given an integer N, write N as a sum of lucky numbers. If several representations are possible, output one that uses the fewest numbers. If there is still more than one such representation, output the lexicographically smallest sequence.
For two representations with the same number of terms,
N = a1 + a2 + ... + ak
comes before
N = b1 + b2 + ... + bk
if, at the first index i where ai and bi differ, ai < bi. If N cannot be represented as a sum of lucky numbers, output -1.
The first line contains the integer N. N is at most 1,000,000,000.
Print the answer on one line, with numbers separated by spaces.