#P1411B. Fair Numbers
Fair Numbers
Description
We call a positive integer number fair if it is divisible by each of its nonzero digits. For example, is fair (because it is divisible by and ), but is not, because it isn't divisible by . Given a positive integer . Find the minimum integer , such that and is fair.
The first line contains number of test cases (). Each of the next lines contains an integer ().
For each of test cases print a single integer — the least fair number, which is not less than .
Input
The first line contains number of test cases (). Each of the next lines contains an integer ().
Output
For each of test cases print a single integer — the least fair number, which is not less than .
Note
Explanations for some test cases:
- In the first test case number is fair itself.
- In the second test case number is fair (it's divisible by both and ). None of the numbers from is fair, because, for example, none of them is divisible by .