XOR with Subset

All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
You have an array of integers A_{1}, A_{2}, ..., A_{N}. The function F(P), where P is a subset of A, is defined as the XOR (represented by the symbol ⊕) of all the integers present in the subset. If P is empty, then F(P)=0.
Given an integer K, what is the maximum value of K ⊕ F(P), over all possible subsets P of A?
Input
The first line contains T, the number of test cases. Each test case consists of N and K in one line, followed by the array A in the next line.
Output
For each test case, print the required answer in one line.
Constraints
 1 ≤ T ≤ 10
 1 ≤ K, A_{i} ≤ 1000
 Subtask 1 (30 points):1 ≤ N ≤ 20
 Subtask 2 (70 points):1 ≤ N ≤ 1000
Example
Input: 1 3 4 1 2 3 Output: 7
Explanation
Considering all subsets:
F({}) = 0 ⇒ 4 ⊕ 0 = 4
F({1}) = 1 ⇒ 4 ⊕ 1 = 5
F({1,2}) = 3 ⇒ 4 ⊕ 3 = 7
F({1,3}) = 2 ⇒ 4 ⊕ 2 = 6
F({1,2,3}) = 0 ⇒ 4 ⊕ 0 = 4
F({2}) = 2 ⇒ 4 ⊕ 2 = 6
F({2,3}) = 1 ⇒ 4 ⊕ 1 = 5
F({3}) = 3 ⇒ 4 ⊕ 3 = 7
Therefore, the answer is 7.
Author:  darkshadows 
Tester:  xiaodao 
Editorial  http://discuss.codechef.com/problems/XORSUB 
Tags  bit, darkshadows, dec14, dynamicprogramming, simple 
Date Added:  30092014 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions