Distinct Digits

No attempts yetTime limit1sMemory limit128 MB

Problem

Given a positive integer nn, write a program that finds the multiple mm of nn whose decimal representation is made up of the fewest distinct digits. For example, 13341334 is made up of the distinct digits 1,3,41, 3, 4 (three of them).

Input

The input consists of several test cases. Each test case is a single line containing the integer nn. There are at most 5050 test cases, and nn is a natural number not greater than 6553665536. The last line of the input contains a single 00, which marks the end of the input.

Output

For each test case, print the value mm defined above, one per line. If more than one such mm exists, print the smallest one.