Under construction

Still being built. Things may change

Galactic Bonus

Time limit0.4sMemory limit8 MB

Summary
For each age up to 2^64 - 1, find the smallest base in which the number has exactly two digits equal to 1 and all other digits 0.
Level

Medium6 of 10

Topics
Math, Binary search, Number theory
Solved
No attempts yet

Problem

The Parliament of the Galactic Federation is losing popularity, so it decided to pay a bonus to citizens whose age in years is a round number. Years have the same length on all planets thanks to the Standard Galactic Calendar.

Some species use different bases in their number systems, so critics said "round numbers" cannot be defined. After long debate, the Parliament ruled that an age AA is round if it can be written as 100…100…100\ldots100\ldots in some base BB. That means exactly two digits are 1, and all other digits are 0. The bonus is the smallest base BB in which AA is round.

Once the law took effect, the Parliament needed a fast way to compute the bonuses. Given the number of citizens NN and each citizen's age AiA_i, find the lowest base in which each age is round.

Input

The first line contains an integer NN, the number of citizens. Each of the next NN lines contains one integer age AiA_i.

Output

Print NN lines. Line ii contains the lowest base in which AiA_i is a round number.

Constraints

1≤N≤100,0001 \le N \le 100{,}000

3≤Ai≤264−13 \le A_i \le 2^{64} - 1 for every ii.

Hints

36=100100236 = 100100_2

26=101526 = 101_5

80=1010000280 = 1010000_2

56=110756 = 110_7

125=11124125 = 11_{124}

Some numbers are round in several bases. For example, 36 is also round in base 3, since 36=1100336 = 1100_3. The answer must still be the lowest base, so the answer for 36 is 2.

Examples1

  1. Example 1

    Input
    5
    36
    26
    80
    56
    125
    
    Expected output
    2
    5
    2
    7
    124