Under construction

Still being built. Things may change

Historic Breakthrough

Time limit2sMemory limit512 MB

Summary
Given m, find n such that m equals the sum of integers in 1..n coprime to n, which also equals n*phi(n)/2.
Level

Hard8 of 10

Topics
Number theory, Math, Implementation, Brute force
Solved
No attempts yet

Problem

Rikka is taking the undergraduate cryptography course this year. In class, it is mentioned that a new method of factorization was recently discovered and is regarded as a historic breakthrough in cryptography. Rikka believes that comparable algorithms exist for some specific class of numbers with simpler goals.

Now you are asked to design and implement such a "factorization" algorithm: given an integer mm, print an integer nn such that

m=nφ(n)2=∑1≤i≤n,gcd(i,n)=1i.m = \frac{n \varphi(n)}{2} = \sum\limits_{\begin{array}{c}1 \le i \le n, \\ \mathrm{gcd}(i, n) = 1\end{array}} i \text{.}

It is guaranteed that such an nn exists in every test case.

Input

The first line of input contains an integer TT (1≤T≤511 \le T \le 51), the number of test cases.

The ii-th of the following TT lines contains a single integer mim_i (0<mi<10360 < m_i < 10^{36}).

Output

For each test case, print an integer nin_i for the corresponding mim_i. It is guaranteed that the answer exists in every test case. If there are several possible answers, print any one of them.

Examples1

  1. Example 1

    Input
    3
    20
    21
    475750381222420656586462245096576000
    
    Expected output
    10
    7
    1497700821900508526