#P3704. [SDOI2017] 数字表格

    ID: 1274 远端评测题 2000~3000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2017各省省选山东O2优化枚举,暴力莫比乌斯反演块状链表,块状数组,分块

[SDOI2017] 数字表格

Description

Doris used her teacher’s supercomputer to generate an n×mn \times m table.

The number in the ii-th row and the jj-th column is fgcd(i,j)f_{\gcd(i,j)}, where gcd(i,j)\gcd(i,j) denotes the greatest common divisor of ii and jj.

There are n×mn \times m numbers in total in Doris’s table. She wants to know the product of all these numbers.

Output the answer modulo 109+710^9+7.

Input Format

There are multiple test cases in a single test file.

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

Each of the next TT lines contains two integers n,mn, m, describing one test case.

Output Format

For each test case, output one integer on a separate line representing the answer.

3
2 3
4 5
6 7
1
6
960

Hint

Constraints:

  • For 10%10\% of the testdata, n,m102n, m \leq 10^2.
  • For 30%30\% of the testdata, n,m103n, m \leq 10^3.
  • For another 30%30\% of the testdata, T3T \leq 3.
  • For 100%100\% of the testdata, 1T1031 \leq T \leq 10^3, 1n,m1061 \leq n, m \leq 10^6.

Translated by ChatGPT 5