#P7486. 「Stoi2031」彩虹

「Stoi2031」彩虹

Description

Hong is a girl who likes to daydream. She thinks the dependence value of two positive integers i,ji, j is lcm(i,j)lcm(i,j)\operatorname{lcm}(i,j)^{\operatorname{lcm}(i,j)}. She defines the product of the dependence values of all i,ji, j satisfying lir,ljrl \le i \le r, l \le j \le r as the obstacle value of two positive integers l,rl, r. Now she gives you a positive integer nn, and asks you tt queries. In each query, you are given two positive integers l,rl, r satisfying 1lrn1 \le l \le r \le n. You need to output the obstacle value ansmod32465177ans \bmod{32465177}.

Input Format

The first line contains two positive integers t,nt, n.

The next tt lines each contain two positive integers li,ril_i, r_i, representing one query.

Output Format

For each query, output one integer representing the answer.

3 7
1 3
2 3
7 7

21072733
12145631
823543

Hint

Brief statement:

Given l,rl, r, compute $\prod\limits_{i=l}^{r}\prod\limits_{j=l}^{r}\operatorname{lcm}(i,j)^{\operatorname{lcm}(i,j)} \bmod{32465177}$. There are multiple queries.

Sample explanation:

For the 1st query, $ans = 1^1 \times (2^2)^3 \times (3^3)^3 \times (6^6)^2$, and ansmod32465177=21072733ans \bmod{32465177} = 21072733.

For the 2nd query, ans=22×33×(66)2ans = 2^2 \times 3^3 \times (6^6)^2, and ansmod32465177=12145631ans \bmod{32465177} = 12145631.

For the 3rd query, ans=77=823543ans = 7^7 = 823543.

Constraints:

For 30%30\% of the testdata, 1n103,t=11 \le n \le 10^3, t = 1.

For 60%60\% of the testdata, 1n105,t=11 \le n \le 10^5, t = 1.

For 100%100\% of the testdata, $1 \le n \le 10^6, 1 \le t \le 10, 1 \le l_i \le r_i \le n$.

Translated by ChatGPT 5