Magic set
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given a sequence of integers a[1]
, a[2]
, ..., a[n]
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 (1 ≤ n ≤ 30) and m (1 ≤ m ≤ 1000). The second line contains n integers a[1]
, a[2]
, ..., a[n]
(1 ≤ a[i]
≤ 1000).
Output
For each test case, print a single line containing one integer - the number of good subsequences.
Examples
Input #1
Answer #1
Submissions 52
Acceptance rate 50%