#d2960. 一个大整数

一个大整数

A Big Integer

Problem Description

You are given a very large integer xx, which can be written as x=∏i=1npicix = \prod_{i = 1}^{n} p_i^{c_i}, where pip_i is a prime. How many pairs of coprime factors of xx are there?

Input Format

The first line gives an integer TT (1≤T≤1021 \le T \le 10^2), the number of test cases.

For each test case, the first line gives an integer nn (1≤n≤1041 \le n \le 10^4).

The following nn lines each give two integers pip_i and cic_i, with 1≤pi,ci≤1091 \le p_i, c_i \le 10^9. It is guaranteed that each pip_i is a prime and that they are pairwise distinct.

Output Format

Output TT lines, each containing one integer: the answer for that test case. The answer may be very large, so output it modulo 109+710^9 + 7.

Sample Input

1
2
2 2
3 1

Sample Output

15

Sample Explanation

x=12x = 12, whose factors are 1,2,3,4,6,121, 2, 3, 4, 6, 12.

The coprime factor pairs are:

(1,1),(1,2),(1,3),(1,4),(1,6)(1, 1), (1, 2), (1, 3), (1, 4), (1, 6)

(1,12),(2,1),(2,3),(3,1),(3,2)(1, 12), (2, 1), (2, 3), (3, 1), (3, 2)

(3,4),(4,1),(4,3),(6,1),(12,1)(3, 4), (4, 1), (4, 3), (6, 1), (12, 1)

for a total of 1515 pairs.