Limits 1s, 512 MB

Many many years ago there was a small country. And all the people there were very weird. They liked unusual stuffs and had unusual habits. But those people were very good at technical stuffs. Anyways that is not the important thing here. In that city was a genius boy named Ezio. He was so good at math stuff that people started to get jealous of him. And day by day he also got cocky. His math teacher was Tahmid sir. Who is very cunning and wise. And he made a problem for him to break Ezio's cockyness.
So he gave Ezio this problem which he was unable to solve.

Now, you are given the same problem. You are a very good programmer can you solve the task with your awesome coding skills.

You are given an array of NN integers. You need to count the number of contiguous sub-segment, which has a sum divisible by KK and the sum is between AA and BB.

Input

There will TT (1T1001 ≤ T ≤ 100) test cases.

Every case will have 3 lines each. First line contain NN the number of integers in the array. The second line will contain NN (1N1051 ≤ N ≤ 10^5) integers A1A_1, A2A_2, ..., AnA_n (1Ai10121 ≤ A_i ≤ 10^{12}) denoting the elements of the array.

Third line will contain three integers KK (1K10181 \le K \le 10^{18}), AA and BB (1AB10181 ≤ A ≤ B ≤ 10^{18}).

Note: sumation of NN in in all test cases doesn't exceed 10610^6.

Output

Print exactly TT lines, each containing a single integer which is the answer to the corresponding test case.

Sample

InputOutput
1
5
1 2 3 4 5
3 1 15
Case 1: 7

Submit

Login to submit.

Statistics

75% Solution Ratio
Matrix.codeEarliest, Aug '17
kali1314Fastest, 0.1s
mamun4122Lightest, 2.5 MB
emoncseShortest, 895B
Toph uses cookies. By continuing you agree to our Cookie Policy.