For two integers a and b, integer d is their common divisors if and only if d divides both a and b. For example, 9 is a common divisor of 18 and 27, while 6 is not.
Among all common divisors of two integers a, b there always exists the largest one. Such a divisor is call the greatest common divisor, often denoted as gcd(a,b), and it is one of the most fundamental concepts in number theory.
This problem focuses on gcd function.
For a given integer Q the task is to answer Q queries, each one defined by a single integer n:
where φ(m) is called Euler’s totient function and it counts the positive integers j≤m, for which gcd(m,j)=1. For example, φ(4)=2, because there are two integers not greater than 4, for which their greatest common divisor with 4 is 1, these numbers are 1 and 3.
Since all the above values can be very large, the goal is to compute their values modulo 109+7.
Input format:
In the first line there is a single integer Q denoting the number of queries. In each of the following Q lines there are two integers t and n, where t is either 1,2 or 3 and denotes the type of the query, and n denotes the parameter of the query.
Output format:
Output exactly Q lines. In the ith of them output the answer to the ith query computed modulo 109+7.
Constraints:
1≤Q≤105
1≤N≤105
There are 3 test cases to handle:
For the first query, superpowers(4), the answer is equal to:
41⋅gcd(1,4)+42⋅gcd(2,4)+43⋅gcd(3,4)+44⋅gcd(4,4)=1124
For the second query, superexps(4), the answer is equal to:
24+1⋅gcd(1,4)+24+2⋅gcd(2,4)+24+3⋅gcd(3,4)+24+4⋅gcd(4,4)=1312
For the third query, superphis(4), the answer is equal to:
φ(41)⋅gcd(1,4)+φ(42)⋅gcd(2,4)+φ(43)⋅gcd(3,4)+φ(44)⋅gcd(4,4)=562