Mysterious ritual#11031

Mysterious ritual

1 second
128 megabytes
Medium

Kratos found a book that describes a mysterious ritual. Initially, you can choose any number . You can do the following:

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.

Input

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 .

Output

For each test print one number on a new line - the minimum value that will ever equal to during the ritual.

Examples

Example 1

Loading
Loading