luogu#P5176. 公约数

公约数

Background

In the last five minutes before collecting the papers, pg found that there was still a major problem on the back side of the paper.

Problem Description

Compute

Since the answer may be too large, output the value of the answer modulo 109+710^9+7.

Input Format

The first line contains a positive integer TT, the number of test cases.

The next TT lines each contain 33 integers: n,m,pn, m, p.

Output Format

Output TT lines. Each line contains one integer, the answer.

2
10 12 11
30 20 25
25302
573830

Hint

For the first 10%10\% of the testdata, T=5T = 5, and 40n,m,p10040 \le n, m, p \le 100.

For another 20%20\% of the testdata, T=50T = 50, and 100n,m,p5×104100 \le n, m, p \le 5 \times 10^4.

For another 20%20\% of the testdata, T=20T = 20, and 4×106n,m,p5×1064 \times 10^6 \le n, m, p \le 5 \times 10^6.

For the remaining 50%50\% of the testdata, T=103T = 10^3, and 107n,m,p2×10710^7 \le n, m, p \le 2 \times 10^7.

Translated by ChatGPT 5