You are given an integer N. Your task is to construct the smallest possible positive integer that satisfies two conditions:
1) The sum of its digits is exactly N.
2) All of its digits are unique (digits from 1 to 9 can be used at most once).
If it's impossible to form such a number, you should return -1.
Input Format:
A single line containing the integer N.
Output Format:
Print a single integer representing the smallest number that meets the criteria.
If no such number can be formed, print -1.
Note:
To make the resulting number as small as possible, it should have the fewest digits. To achieve the sum N with the fewest unique digits, we should greedily pick the largest available digits (9, then 8, then 7, and so on).
Once we have the set of digits that sum to N, we must arrange them in ascending order to form the smallest possible number.
The sum of all unique digits from 1 to 9 is 1+2+...+9 = 45. If N is greater than 45, it is impossible to form the number, so the answer must be -1.