XORX - x-Xor It!

no tags 

Given an array of n integers and a number x. Your task is very simple. You have to find the subarray (length > 0) whose xor is maximum with x. Let's say the subarray as maxsubarray. You have to print the xor value of maxsubarray.

Input

First line of input consists of t test cases.

Second line of input contains two integers n and x.

Third line contains n space separated integers denoting the elements of array.

Output

First and only line of output is xor value of maxsubarray.

Constraints

1 ≤ t ≤ 10

1 ≤ n ≤ 200000

1 ≤ x ≤ 2×109

1 ≤ arr[i] ≤ 2×109 where arr[i] is any integer of array.

Example

Input:
1
3 7
1 2 3

Output:
0

taking 1^2^3 is 0 when taken xor with 7 gives us the maximum xor value.


hide comments
princemishra: 2021-11-26 10:09:49

INPUT-----

2
15 15
26 7 8 21 3 5 6 5 9 4 2 6 5 2 2
10 16
1 2 3 4 5 6 7 8 9 10

OUTPUT-----
16
15

Last edit: 2021-11-26 10:11:23
anonymous: 2020-05-08 16:29:13

There are test cases which do not satisfy specified constraints:

1<=t<=10
1<=n<=200000
1<=x<=2*10^9

kshubham02: 2019-11-24 11:14:48

O(n*size_of_int) = O(n*32) is giving TLE! Is there a better solution?

EDIT : (C++) : String concatenation is a costly operation
Documentation for + operator on string ->
Complexity
Unspecified, but generally linear in the resulting string length (and linear in the length of the non-moved argument for signatures with rvalue references).

Last edit: 2019-11-24 11:54:36
vishal1510: 2018-10-01 15:47:14

Can't be empty.

pugachag: 2018-10-01 15:28:30

In my AC submission I didn't consider empty subarrays, so you can safely assume that it can't be empty

:D: 2018-10-01 13:14:31

Can the subarray be empty?
(Ok, thanks for answering)

Last edit: 2018-10-01 21:28:16

Added by:kumarvishalgupta
Date:2018-09-30
Time limit:1.399s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All