QOJ.ac

QOJ

时间限制: 5 s 内存限制: 128 MB 总分: 100

#2856. Number Table

统计

Doris has just learned about the Fibonacci sequence. Let $f[i]$ denote the $i$-th term of the sequence, where:

$$f[0] = 0$$ $$f[1] = 1$$ $$f[n] = f[n - 1] + f[n - 2], n \geq 2$$

Doris's supercomputer has generated an $n \times m$ table, where the number in the $i$-th row and $j$-th column is $f[\gcd(i, j)]$, and $\gcd(i, j)$ denotes the greatest common divisor of $i$ and $j$.

Doris has an $n \times m$ table and wants to know the product of all these numbers.

Since the product of these numbers is extremely large, Doris only wants to know the result modulo $1000000007$.

Input

The input contains multiple test cases. The first line contains an integer $T$, representing the number of test cases. Each of the following $T$ lines contains two integers $n$ and $m$.

Output

Output $T$ lines, where the $i$-th line is the result for the $i$-th test case.

Examples

Input 1

3
2 3
4 5
6 7

Output 1

1
6
960

Constraints

For $10\%$ of the data, $1 \leq n, m \leq 100$ For $30\%$ of the data, $1 \leq n, m \leq 1000$ Additionally, for $30\%$ of the data, $T \leq 3$ For $100\%$ of the data, $T \leq 1000, 1 \leq n, m \leq 10^6$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.