Nasser gives you an array of length .
You are given queries. Each query contains two integers and .
For each query, you need to count the number of triples (i, j, k) such that:
1 \le i < j < k \le n
l \le \gcd(a[i], a[j], a[k]) \le r
Since the answer can be very large, output it modulo 10^9 + 7.
Each test contains multiple test cases. The first line contains a single integer (1 \le t \le 10^4) — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers and (3 \le n \le 2 \cdot 10^5, 1 \le q \le 2 \cdot 10^5).
The second line of each test case contains integers a_1, a_2, \ldots, a_n (1 \le a_i \le n) — the elements of the array.
The next lines each contain two integers and (1 \le l \le r \le n).
It is guaranteed that the sum of over all test cases does not exceed 2 \cdot 10^5, and the sum of over all test cases does not exceed 2 \cdot 10^5.
For each query, print a single integer — the number of triples (i, j, k) with in [l, r], modulo 10^9 + 7.
Example 1
In the first test case, n=6, q=2, a=[2,3,2,5,6,6]:
Query : l=2, r=4. We need triples (i,j,k) where 2 \le \gcd(a_i, a_j, a_k) \le 4.
(1,3,5): \gcd(2,2,6)=2. Valid.
(1,3,6): \gcd(2,2,6)=2. Valid.
(1,5,6): \gcd(2,6,6)=2. Valid.
(3,5,6): \gcd(2,6,6)=2. Valid.
(5,6,?): We need a third element. \gcd(6,6,2)=2, \gcd(6,6,3)=3.
(2,5,6): \gcd(3,6,6)=3. Valid.
There are valid triples. The answer is .
Query : l=3, r=4. We need triples (i,j,k) where 3 \le \gcd(a_i, a_j, a_k) \le 4.
(2,5,6): \gcd(3,6,6)=3. Valid.
There is valid triple. The answer is .
Subtask ( points) : (3 \le \sum n \le 50, 1 \le \sum q \le 50)
Subtask ( points) : (3 \le \sum n \le 500, 1 \le \sum q \le 500)
Subtask ( points) : (3 \le \sum n \le 2000, 1 \le \sum q \le 2000)
Subtask ( points) : No additional constraints.