You are given a string 'S' that consists of I’s and D’s pattern only. 'I' is for increasing, and 'D' is for decreasing. Your task is to return the string that consists of a minimum number following that pattern.
Note:
1) Digits of the number should be in the range [1,9] and can’t repeat.
2) The length of the string should be less than or equal to 8.
Input Format:
The first line of the input contains an integer 'T' denoting the number of test cases.
The first line of each test case contains a string 'S', as described in the problem statement.
Output Format:
For each test case, return a string consisting of a minimum number following the given pattern.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 10^3
1 <= |S| <= 8
where |S| is the length of the given string.
Time Limit: 1sec