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 (l_i,r_i). Your task is to calculate the number of such subsequences a_j_1,a_j_2,…,a_j_k that l_i≤j_1<j_2<…<j_k≤r_i and (a_j_1+a_j_2+…+a_j_k)modm=0. In other words, you need to calculate the number of subsequences of subarray \[a_l_i,a_l_i+1,…,a_r_i] such that the sum of elements in each subsequence is divisible by m.
The first line contains two integers n and m: the number of elements in a and the modulo (1≤n≤2⋅105, 1≤m≤20).
The second line contains n integers a_i: the elements of array a (0≤a_i≤109).
The third line contains one integer q: the number of queries (1≤q≤2⋅105).
Then q lines follow. The i-th of these lines contains two integers l_i and r_i that describe the i-th query (1≤l_i≤r_i≤n).
Print q lines. The i-th of them must contain the answer for the i-th query. Queries are indexed in the order they are given in the input. Since the answers can be very large, print them modulo 109+7.