#P7854. Kidnapper's Matching Problem
Kidnapper's Matching Problem
Kidnapper's Matching Problem
Problem Description
It is preferrable to read the pdf statment. One day when you were sitting in the couch and eating chips, a guy called you, who claimed that his name was Cuber QQ and he had your girlfriend kidnapped. This seems quite unlikely to you because you do not even have a girlfriend. However, to kill the boring time of Sunday afternoon, you asked how much the ransom is. Surprisingly, Cuber QQ is not interested in your money, the ransom is the answer to a matching problem. It turns out that Cuber QQ is a lover of binary operators, xor especially. First of all, he shall give you a pair of sequences and , with length and respectively. Given that and do not necessarily have the same length, they do not exactly make a pair . Therefore consecutive subsequences of are used to make pairs with , That makes pairs: and for all . For each pair , we say they are xor-matched if their pairwise-xor 's are all available in a pre-defined set . Concretely, the pair is a match if and only if of all . is defined as the set of all possible xor-sum of 's subsets, i.e.,
$$2_{\oplus}^{S} = \{ t | t = \bigoplus_{w \in X} w, X \subseteq S \} $$Note that, since is always a valid subset of , is always included in . Now Cuber QQ wants you to tell him, for which 's, makes a match with . He is not sending your illusory girlfriend back before you correctly answer his question.
Input
The first line contains an integer (), denotes the number of test cases. Each test case begins with three space-separated integers (), ()) and (), denoting the lengths of , and the size of . The next line contains space-separated integers (). The next line contains space-separated integers (). The last line contains space-separated integers (). It is guaranteed that $\sum n \le 1.2 \cdot 10^6, \sum m \le 3 \cdot 10^5, \sum k \le 6 \cdot 10^5$.
Output
For each case, you should output:
$$\sum_{i = 1}^{n - m + 1} [(a_i, a_{i + 1}, \cdots, a_{i + m - 1}) \text{ matches } b] \cdot 2^{i - 1} \bmod (10^9 + 7) $$where equals 1 if holds and otherwise.
Sample Input
2
4 2 2
2 5 7 6
3 4
5 6
13 3 3
1 1 4 5 1 4 1 9 1 9 8 1 0
2 5 1
1 2 15
Sample Output
2
80
Source
2020 Multi-University Training Contest 8