eolymp
bolt
Try our new interface for solving problems
Problems

Magic set

Magic set

Given a sequence of integers a1, a2, ..., an and an integer m.

Lets define a good sequence of integers as a non-empty sequence such that the sum of the elements in each of its non-empty subsequences is divisible by m.

Find the number of good subsequences of the sequence a.

Input

The first line contains the number of test cases t. The first line of each test case contains two space-separated integers n (1n30) and m (1m1000). The second line contains n integers a1, a2, ..., an (1ai1000).

Output

For each test case, print a single line containing one integer - the number of good subsequences.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3
2 3
1 2
2 3
1 3
9 3
9 10 11 12 13 14 15 21 22
Output example #1
0
1
15