Time limit
1s
Memory limit
512 MB
A non-negative integer is called a decreasing number if each digit is strictly smaller than the digit immediately to its left, from the most significant digit to the least significant digit. For example, 321 and 950 are decreasing numbers, but 322 and 958 are not.
Given N, print the N-th decreasing number when all decreasing numbers are sorted in increasing order. The number 0 is the 0-th decreasing number, and 1 is the 1st decreasing number. If the N-th decreasing number does not exist, print -1.
The first line contains N. N is either 0 or a natural number not greater than 1,000,000.
Print the N-th decreasing number on the first line. If it does not exist, print -1.