DreamGrid has an integer sequence $a_1, a_2, \dots, a_n$ and he likes it very much. Unfortunately, h

DreamGrid has an integer sequence a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1,a2,,an and he likes it very much. Unfortunately, his naughty roommate BaoBao swapped two elements a i a_i ai and a j a_j aj ( 1 ≤ i < j ≤ n 1 \le i < j \le n 1i<jn) in the sequence when DreamGrid wasn’t at home. When DreamGrid comes back, he finds with dismay that his precious sequence has been changed into a 1 , a 2 , … a i − 1 , a j , a i + 1 , … , a j − 1 , a i , a j + 1 , … , a n a_1, a_2, \dots a_{i-1}, a_j, a_{i+1}, \dots, a_{j-1}, a_i, a_{j+1}, \dots, a_n a1,a2,ai1,aj,ai+1,,aj1,ai,aj+1,,an!

What’s worse is that DreamGrid cannot remember his precious sequence. What he only remembers are the two values x = ∑ k = 1 n k a k and y = ∑ k = 1 n k a k 2 x = \sum_{k=1}^nka_k \qquad \text{and} \qquad y = \sum_{k=1}^nka_k^2 x=k=1nkakandy=k=1nkak2 Given the sequence after swapping and the two values DreamGrid remembers, please help DreamGrid count the number of possible element pairs ( a i , a j ) (a_i, a_j) (ai,aj) BaoBao swaps.

Note that as DreamGrid is poor at memorizing numbers, the value of x x x or y y y might not match the sequence, and no possible element pair can be found in this situation.

Two element pairs ( a i , a j ) (a_i, a_j) (ai,aj) ( 1 ≤ i < j ≤ n 1 \le i < j \le n 1i<jn) and ( a p , a q ) (a_p, a_q) (ap,aq) ( 1 ≤ p < q ≤ n 1 \le p < q \le n 1p<qn) are considered different if i ≠ p i \ne p i=p or j ≠ q j \ne q j=q.
Input

There are multiple test cases. The first line of the input contains an integer T T T, indicating the number of test cases. For each test case:

The first line contains three integers n n n, x x x and y y y ( 2 ≤ n ≤ 1 0 5 , 1 ≤ x , y ≤ 1 0 18 2 \le n \le 10^5, 1 \le x, y \le 10^{18} 2n105,1x,y1018), indicating the length of the sequence and the two values DreamGrid remembers.

The second line contains n n n integers b 1 , b 2 , … , b n b_1, b_2, \dots, b_n b1,b2,,bn ( 1 ≤ b i ≤ 1 0 5 1 \le b_i \le 10^5 1bi105), indicating the sequence after swapping. It’s guaranteed that ∑ k = 1 n k b k ≤ 1 0 18 \sum\limits_{k=1}^n kb_k \le 10^{18} k=1nkbk1018 and ∑ k = 1 n k b k 2 ≤ 1 0 18 \sum\limits_{k=1}^n kb_k^2 \le 10^{18} k=1nkbk21018.

It’s guaranteed that the sum of n n n of all test cases will not exceed 2 × 1 0 6 2 \times 10^6 2×106.
Output

For each test case output one line containing one integer, indicating the number of possible element pairs BaoBao swaps.
Sample Input

2
6 61 237
1 1 4 5 1 4
3 20190429 92409102
1 2 3

Sample Output

2
0

Hint

For the first sample test case, it’s possible that BaoBao swaps the 2nd and the 3rd element, or the 5th and the 6th element.

你可能感兴趣的:(DreamGrid has an integer sequence $a_1, a_2, \dots, a_n$ and he likes it very much. Unfortunately, h)