#P7501. [2017年杭电多校]All Kill

[2017年杭电多校]All Kill

All Kill

Problem Description

Give nonnegative integers x1¡­nx_{1¡­n} which are less than 3267732677, calculate yi,j=xi×xjmod32677y_{i,j}=x_i\times x_j\mod32677. HazelFan wants to know how many sextuples (a,b,c,d,e,f)(a,b,c,d,e,f) are there, satisfies $\gcd(y_{a,b},y_{c,d})=\gcd(y_{c,d},y_{e,f})=\gcd(y_{e,f},y_{a,b})=1$, module 2302^{30}.

Input

The first line contains a positive integer T(1T5)T(1\leq T\leq5), denoting the number of test cases. For each test case: The first line contains a positive integer n(1n2×105)n(1\leq n\leq2\times10^5). The second line contains nn nonnegative integers x1...n(0xi<32677)x_{1...n}(0\leq x_i<32677).

Output

For each test case: A single line contains a nonnegative integer, denoting the answer.

Sample Input

2

1

1

5

1 2 3 4 5

Sample Output

1

1087

Source

2017 Multi-University Training Contest - Team 7

https://acm.hdu.edu.cn/showproblem.php?pid=6120