Kratos found a book that describes a mysterious ritual. Initially, you can choose any number . You can do the following:
Remember the least significant digit of the number in decimal notation.
Until is completely divisible by , add the memorized digit.
Divide by and return to the beginning of the ritual.
The ritual continues indefinitely, the book says that the smallest number that will be equal to during this ritual is magical. Kratos has not yet decided which initial to choose. Help him determine the corresponding magic number for each initial option.
The first line gives the number of tests (1 \le t \le 10^5). Each of the next lines contains a single integer n_i (1 \le n_i < 10^{500001}) - the initial value of in the -th test. The total length of numbers in all tests does not exceed .
For each test print one number on a new line - the minimum value that will ever equal to during the ritual.
Example 1