#P7789. Tokitsukaze and Multiple

Tokitsukaze and Multiple

Tokitsukaze and Multiple

Problem Description

Tokitsukaze has a sequence of length nn, denoted by aa. Tokitsukaze can merge two consecutive elements of aa as many times as she wants. After each operation, a new element that equals to the sum of the two old elements will replace them, and thus the length of aa will be reduced by 11. Tokitsukaze wants to know the maximum possible number of elements that are multiples of pp she can get after doing some operations (or doing nothing) on the sequence aa.

Input

There are several test cases. The first line contains an integer TT (1T20)(1 \leq T \leq 20), denoting the number of test cases. Then follow all the test cases. For each test case, the first line contains two integers nn and pp (1n,p105)(1 \leq n, p \leq 10^5), denoting the length of the sequence and the special number, respectively. The second line contains nn integers, where the ii-th integer aia_i (1ai105)(1 \leq a_i \leq 10^5) is the ii-th element of aa. It is guaranteed that the sum of nn in all test cases is no larger than 10610^6.

Output

For each test case, output in one line the maximum possible number of elements that are multiples of pp after doing some operations.

Sample Input

2
5 3
2 1 3 2 1
3 1
123 456 789

Sample Output

3
3

Source

2020 Multi-University Training Contest 3