#K86007. Find the Next Special Number
Find the Next Special Number
Find the Next Special Number
You are given a positive integer N. Your task is to find the smallest special number strictly greater than N.
A number is considered special if it satisfies the following conditions:
- It is an odd number, i.e. $$N \bmod 2 \neq 0$$.
- All of its digits are unique; in other words, if the number is represented in base 10, no digit appears more than once.
For example:
- 125 is special since it is odd and its digits (1, 2, 5) are all unique.
- 1023457 is special since it is odd and its digits are all unique.
- 1234 is not special because it is even.
- 112 is not special because it has repeated digit '1'.
Your program should take multiple test cases as input and produce the result for each test case on a new line.
inputFormat
The first line of input consists of a single integer T which denotes the number of test cases.
Each of the next T lines contains a single integer N.
Input is provided via standard input (stdin).
outputFormat
For each test case, output the smallest special number greater than N on a separate line using standard output (stdout).
## sample5
123
100
998765
0
8
125
103
1023457
1
9
</p>