#P9880. GG and YY's Binary Number
GG and YY's Binary Number
GG and YY's Binary Number
Problem Description
GG and YY are honing their skills with binary numbers. They have a set comprising binary numbers: . Additionally, they have queries determined by intervals . For each query interval , they aim to compute the count of unique subsets taken from such that the xor sum of the elements of lies within . The results should be provided modulo . Specifically, for each , compute:
$$\left( \sum_{j \in [l_i, r_i]} \sum_{\{u_1, u_2, \ldots, u_k\} \subseteq V} [u_1 \oplus u_2 \oplus \ldots \oplus u_k = j] \right) \bmod (10^9 + 7) $$where represents the xor operation and square brackets denote the Iverson bracket. Please note that the xor sum of an empty set is . In the Iverson bracket notation, if the condition inside the bracket is true, the value is ; otherwise, it is . For instance, is if the xor sum of equals , and otherwise.
Input
The first line contains one integer (), indicating the number of test cases. The first line of each case contains two integers and (), indicating the size of the sets and . The following line contains binary integers (), indicating the binary integers in . The following lines present the queries. The -th line continas two binary integers (), indicating the query interval. It is guaranteed that there will be no leading zeros in the binary numbers, with the exception of . For instance, the binary number corresponds to the decimal number .
Output
For each test case, output integers in lines, indicating the results of the queries.
Sample Input
1
4 2
100 0 1 101
1 10
10 100
Sample Output
4
4
Source
2023“钉耙编程”中国大学生算法设计超级联赛(8)