BADXOR - Bad XOR

You are given an array A of N elements. Also you are given another array B of M elements. Any subset (i­1, i2, i3 ... ip) is bad IFF (Ai1 ⊕ Ai2 ⊕ ... ⊕ Aip) equals any value of B. (⊕ means Bitwise XOR, which can be found with ^ syntax in popular programming languages.) Now your job is to find the number of good subsets. Empty subset has XOR value of 0.

Input

The first line of input denotes the number of test cases T (1 ≤ T ≤ 20). The first line of each test case contains two integers N and M (0 ≤ N, M ≤ 1000). The next line contains N integers of the array A (0 ≤ Ai ≤ 1000). The next line contains M integers of the array B (0 ≤ Bi ≤ 1000). You can assume that each element of array B will be unique.

Output

For each case, print the case number and the total numbers of good subsets in a line. As the result can be very big, output it modulo 100000007.

Example

Input:
2
2 3
1 2
0 1 2
1 3
1
0 1 2

Output:
Case 1: 1
Case 2: 0

Problem Setter: Nafis Sadique, Special Thanks: Ahmad Faiyaz


Added by:Faiyaz
Date:2013-12-24
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C C++ 4.3.2 CPP JAVA

hide comments
2014-01-01 18:09:14 hanif
is it valid subset (A3,A4,A5)????

reply: only if n >= 5

Last edit: 2014-01-01 18:18:24
2014-01-01 16:36:55 BISHAL GAUTAM
Are u sure value of mod is 100000007 ?
Or, 1000000007 ??

reply : Yes. I am sure it's 100000007.

Last edit: 2014-01-01 17:43:49
2014-01-01 15:04:19 MD:REZAUL KARIM
ip.
What is p here?

reply: p can be any value between 0 to n. if p = 0 then it would refer to empty set.

Last edit: 2014-01-01 15:07:16
2014-01-01 14:04:54 Muhammed Hedayetul Islam
Limit for N and M?
Reply:
0 <= N, M <= 1000

Last edit: 2014-01-01 14:05:21
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.