Medium Accuracy: 16.77% Submissions: 1739 Points: 4

Given an integer N the task is to find the largest number which is smaller or equal to it and has its digits in non decreasing order.

Examples:

Examples:

Input : n = 200
Output : 199
If the given number is 200, the largest
number which is smaller or equal to it
having digits in non decreasing order is
199.
Input : n = 139
Output : 139

Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contain an integer N.

Output:
For each test case in a new line print the required output.