
N = 3
K = 2
A = [ 1, 2, 3 ]
Explanation :
The bitwise ‘AND’ of all subarrays of size <= 2 are :
From index 1 :
Subarray of length 1 has ‘AND’ = 1.
Subarray of length 2 has ‘AND’ = 1 & 2 = 0.
From index 2 :
Subarray of length 1 has ‘AND’ = 2.
Subarray of length 2 has ‘AND’ = 2 & 3 = 2.
From index 3 :
Subarray of length 1 has ‘AND’ = 3.
‘XOR’ of all these ‘AND’ operations = 1 ^ 0 ^ 2 ^ 2 ^ 3 = 2.
So, final result = 2.
The first line contains an integer 'T' which denotes the number of test cases to be run. Then the test cases follow.
The first line of each test case contains two integers ‘N’ and ‘K’.
The second line of each test case contains an array ‘A’ of size ‘N’.
For each test case, print one integer denoting the final result after performing the operations.
Print the output of each test case in a new line.
You don’t need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 10^5
1 <= K <= N
1 <= A[i] <= 10^5
Time Limit : 1 sec
Algorithm :
Algorithm :