Time limit
2s
Memory limit
128 MB
A nonnegative integer is called a decreasing number if, when written in decimal notation, each digit is strictly smaller than the digit immediately to its left. For example, 321 and 950 are decreasing numbers, while 322 and 958 are not.
Given a positive integer N, print the N-th smallest decreasing number. The smallest decreasing number is 0, so it is the 1st one. If the N-th decreasing number does not exist, print -1.
The first line contains a positive integer N. N is at most 1,000,000.
Print the N-th smallest decreasing number on the first line. If it does not exist, print -1.