Problem J. Subsequence Sum Queries
Output file: standard output
Time limit: 3 seconds
Memory limit: 256 mebibytes
You have an array a containing n integers and an integer m. You also have q queries to answer. The i-th query is described as a pair of integers (li; ri). Your task is to calculate the number of such subsequences aj1; aj2; : : : ; ajk that li ≤ j1 < j2 < : : : < jk ≤ ri and (aj1 + aj2 + : : : + ajk) mod m = 0. In other words, you need to calculate the number of subsequences of subarray [ali; ali+1; : : : ; ari] such that the sum of elements in each subsequence is divisible by m
Input
The first line contains two integers n and m: the number of elements in a and the modulo (1 ≤ n ≤ 2⋅1052·105,1 ≤ m ≤ 20).
The second line contains n integers ai: the elements of array a (0 ≤ ai ≤