Problem AX
The Owl and the Fox
Fox Mithra has finally learned the numbers and he is now familiar with the concept of ‘one’, ’two’, ‘three’ and also even ‘zero’, ‘minus one’, ‘minus two’ and so on. Really, an achievement for such a small fox. He took the textbook and copied the integers from the book one by one from the smallest to the biggest on the wall of his enclosure in the ZOO.
“Look, there is something wrong with your sequence on the
wall”, said the owl who just landed on the branch above
Mithra’s head. “You should put
“Why?”
“Because the importance of a number is judged by the sum of
its digits.
“I see,” replied Mithra, “you are really clever. Can you
help me please to rearrange the sequence correctly? Each time I
tell you a number
“With pleasure,” nodded the owl majestically.
Your task is to imitate the owl’s task. Given an integer
Input
The first line of input contains the number of test cases
Each case consists of a line containing a single integer
Output
For each test case print on a separate line the number demanded by fox Mithra.
Sample Input 1 | Sample Output 1 |
---|---|
4 30 199 1000 1520 |
20 198 0 1510 |