P21103 [CodeChef] APOC2 04
普及
题目描述

CHEF N TIMINGS

One day chef was working with some random numbers. Then he found something
interesting. He observed that no 240, 567, 9999 and 122 and called these numbers
nice as the digits in numbers are in increasing order. Also he called 434, 452, 900
are not nice as digits are in decreasing order

Now you are given a no and chef
wants you to find out largest "nice" integer which is smaller than or equal to the
given integer.

-----Constraints-----

1< t < 1000

1< N < 10^18

-----Input Format-----

First line contains no. of test cases t. Then t test cases follow. Each test case
contain a integer n.

-----Output-----

Output a integer for each test case in a new line which is largest nice
integer smaller or equal to the given integer.

-----Example Text Case-----
Input:

1
132

Output:

129

输入格式

见题面

输出格式

见题面

样例输入
['1', '132']
样例输出
['129']