CODEIT02 - PICK UP DROP ESCAPE

You are given with an array of n numbers. You must pick K elements from the array such that XOR of all the chosen elements is maximum.

See Bitwise XOR.

Input

The first line consists of an integer t representing the number of test cases. For each test case the first line consists of two numbers n and K denoting the number of elements in the array and the number of elements to be chosen respectively. Then in the next n lines, the elements in the array are given.

Output

For each test case print a line containing one integer denoting the maximum XOR value of the chosen K elements.

Constraints

1 ≤ t ≤ 100

1 ≤ n ≤ 20

1 ≤ k ≤ n

1 ≤ element value ≤ 10000

Example

Input:
2
5 3
1
2
3
4
5
5 3
3
4
5
7
4

Output:
7
7

Added by:cegprakash
Date:2012-01-09
Time limit:0.107s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2020-07-04 06:01:09
Applied Brute Force worked for me but when tried the 3dp solution giving me TLE.
2019-11-07 18:44:57
Can I apply bitmask approach here >?
2019-07-11 20:56:13
[spoiler removed]

Last edit: 2019-11-04 16:29:10
2015-06-04 08:10:24 Aman Parashar
Best Solution :)

Last edit: 2015-06-04 08:57:57
2015-05-26 20:33:33 Rishabh Joshi
did this just after XMAX. Didnt interpret the question clearly. got 4-5 WA.
Nice learning though.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.