
ZOJ Problem Set  3940
One day, Peter came across a function which looks like:
Peter wants to know the number of solutions for equation F(N, X) = Y, where Y is a given number. InputThere are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case: The first line contains two integers N and M (2 ≤ N ≤ 10^{5}, 0 ≤ M ≤ 10^{9}). The second line contains N integers: A_{1}, A_{2}, ..., A_{N} (1 ≤ A_{i} ≤ 10^{9}). The third line contains an integer Q (1 ≤ Q ≤ 10^{5})  the number of queries. Each of the following Q lines contains an integer Y_{i} (0 ≤ Y_{i} ≤ 10^{9}), which means Peter wants to know the number of solutions for equation F(N, X) = Y_{i}. OutputFor each test cases, output an integer S = (1 ⋅ Z_{1} + 2 ⋅ Z_{2} + ... + Q ⋅ Z_{Q}) mod (10^{9} + 7), where Z_{i} is the answer for the ith query. Sample Input1 3 5 3 2 4 5 0 1 2 3 4 Sample Output8 HintThe answer for each query is: 4, 2, 0, 0, 0. Author: LIN, Xi Source: The 13th Zhejiang Provincial Collegiate Programming Contest 