One day Sudipto Sir was teaching bit-masking and other bit-manipulation techniques in class. After the class was over he gave an interesting problem to his students to code.
The Problem states: Suppose values of four different sets (A,B,C,D) of size N and a number K are given to you. You have to select four values, one from each set A, B, C and D such that Ai ^ Bi ^ Ci ^ Di = K. (one number Ai from array A, one number Bi from array B,one number Ci from array C and one number Di from array D)
All values in any of the set (A, B, C, D) may or may not be unique.
Output the total number of ways the above selection can be done ?
(Here ^ represents the bitwise XOR operation)
Input Format:
The first line of the input gives the number of test cases T. For each case begins with one line with two space-separated integers, N and K. Then four more lines follow. Each has N space-separated integers and represents the values present in each Array or list.
Input Format:
For each test case, output one line containing "Case #x: y", where x is the test case number (starting from 1) and y is the number of different selections possible.
Constraints:
1 ≤ T ≤ 10
0 ≤ K ≤ 10^9
1 ≤ N ≤ 10^3
0 ≤ Array values ≤ 10^9
( 0 ^ 2 ^ 0 ^ 1 ) == 3 and the selection of values can be done in 4 different ways. Click here for Sample Explanation
In the 1st combination out of four , 0 is selected from array A , 2 is selected from array B , 0 is selected from array C and 1 is selected from array D