#d2960. 一个大整数
一个大整数
A Big Integer
Problem Description
You are given a very large integer , which can be written as , where is a prime. How many pairs of coprime factors of are there?
Input Format
The first line gives an integer (), the number of test cases.
For each test case, the first line gives an integer ().
The following lines each give two integers and , with . It is guaranteed that each is a prime and that they are pairwise distinct.
Output Format
Output lines, each containing one integer: the answer for that test case. The answer may be very large, so output it modulo .
Sample Input
1
2
2 2
3 1
Sample Output
15
Sample Explanation
, whose factors are .
The coprime factor pairs are:
for a total of pairs.