Uncle Bob, the Mayor of Bytelands is not only a great leader but also an enthusiastic problem solver. He is so obsessed with problem solving that he hired a team to create new problems for him everyday. But no matter how hard the problem is, Uncle Bob solves it within a few minutes. As the days pass by, he feels bored with solving such easy problems. So, he threatens the team to come up with an exciting problem or they have to look for a new job. After hours of brainstorming the team came up with the following problem.
Given two arrays of integers A and B, determine the number of non-empty subsets of A where the XOR Sum of the subset does not contain a submask that is present in the array B. More formally, if the XOR SUM of the chosen subset is S and the submasks of S are {m1, m2, ... , mn} then mi ∉ B (1 ≤ i ≤ n). As the number of valid non-empty subsets can be huge, you need to provide the remainder of the answer when divided by 1000,000,007.
A set A is a subset of a set S if all the elements in A are also elements of S. For example, {1, 2} is a subset of {1, 2, 3}. Because the set {1, 2, 3} contains all the elements of set {1, 2}. An empty set {} is also a subset of a set. Here is an example of the all possible subsets of a set {1, 2, 3} = [ {}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}]. If we exclude the empty subset from all possible subsets, then it becomes all possible non-empty subsets. Note that, {1, 4} is not a subset of {1, 2, 3} as the set {1, 2, 3} does not contain 4.
XOR SUM of a set {a1, a2, … , ak} = a1 ⊕ a2 ⊕ ... ⊕ ak (the character ⊕ denotes bitwise XOR)
A submask of a number n represents a bitmask (binary representation of a number) in which a bit can only be set if the bit in the bitmask of n is set at the same position. Here are some of the examples of submasks:
Submasks of 1 (1) = {0, 1}
Submasks of 3 (11) = {00, 01, 10, 11}
Submasks of 5 (101) = {000, 001, 100, 101}
Looking at the problem, Uncle Bob was stunned. He never thought in a million years that he would be given a problem that requires any bitwise operations let alone XOR SUM. Now he regrets threatening the team. He is aware that not being able to solve this problem will harm his reputation as a Mayor. So he hired you to solve it for him. Would you be able to help Uncle Bob and save him from his misery? Also, make sure not to tell anybody that Uncle Bob has hired you!
Input
Input will have multiple test cases. The first line of the input contains an integer, T (1 ≤ T ≤ 100), representing the number of test cases. For each test case:
- The first line contains two positive integers N (1 ≤ N ≤ 105) and K (1 ≤ K ≤ 10) representing the length of the array A and B, respectively.
- The second line contains N space separated integers a1, a2, ... , an (0 ≤ ai ≤ 231 - 1).
- The third line contains K space separated integers b1, b2, ... , bk (0 ≤ bi ≤ 231 - 1).
You can safely assume that the sum of N over all test cases will not exceed 105.
Output
For each case, print the case number followed by the answer modulo 1,000,000,007 (the remainder when divided by 1,000,000,007. Please, see the sample for details.
Sample
Sample Input | Sample Output |
---|---|
3 1 1 1 1 2 1 1 2 4 2 1 1 3 1 | Case 1: 0 Case 2: 3 Case 3: 1 |