Majestic Segments II#12333

Majestic Segments II

1.5 seconds
128 megabytes
Very hard

You're given an array of size and an integer , you must find the number of majestic ranges (l,r) (1 \le l \le r \le n).

A range (l,r) is considered majestic if and only if the Least Common Multiple of all the elements in the range is divisible by , i.e. the following should be true:

ATTENTION ! : this is important , use lichao tree to count without any math shortcuts

\displaystyle \displaystyle \text{LCM}(a_l , a_{l+1} , ... , a_r) \bmod k =0 \\

Input

The first line of the input contains an integer (1 \le t \le 100) the number of testcases.

The description for the test cases follows.

The first line of each test case contains two integers (1 \le n \le 2 \cdot 10^6 , 1 \le k \le 10^{14}) the size of the array .

The second line of each test case contains integers a_1 , a_2 , ... , a_n (1 \le a_i \le 10^{18}) the elements of the array .

It is guaranteed that the sum of over all test cases does not exceed 2 \cdot 10^6.

Output

For each test case output a single integer, the number of majestic ranges.

Examples

Example 1

Loading
Loading

Note

In the first test case , No subarray has that's a multiple of .

In the second test case , The following subarrays satisfies :

  • [2,2,3,4] : \text{LCM}([2,2,3,4])=12 which is multiple of .

  • [2,3,4] : \text{LCM}([2,3,4])=12 which is multiple of .

  • \text{LCM}([3,4])=12 which is multiple of .

Scoring

Let be the sum of over all test cases , Formally m=\sum n.

  • Subtask ( points): (m,k,a_i \le 500)

  • Subtask ( points): (m,k \le 1000)

  • Subtask ( points): (m \le 1000)

  • Subtask ( points): (k \le 10^6)

  • Subtask ( points): (k \le 10^{12})

  • Subtask ( points): no additional constraints