#C5034. Subset XOR Equals Target

    ID: 48639 Type: Default 1000ms 256MiB

Subset XOR Equals Target

Subset XOR Equals Target

You are given an array of integers and a target value ( x ). Your task is to determine whether there exists a subset of the array such that the bitwise XOR (denoted as ( \oplus )) of all its elements equals ( x ). A subset can consist of any collection of elements from the array (not necessarily contiguous) and may even be empty (although note that by definition the XOR of an empty subset is usually taken as 0).

For each test case, print YES if such a subset exists, or NO otherwise.

inputFormat

The input is read from standard input (stdin).

The first line contains an integer ( T ), the number of test cases. Each test case is described as follows:
( n ) — the number of elements in the array.
A line with ( n ) space-separated integers representing the array elements.
A line with an integer ( x ), the target XOR value.

Overall, the input format is as follows:
( T )
For each test case:
( n )
( a_1 \ a_2 \ \dots \ a_n )
( x )

outputFormat

For each test case, output a single line containing either YES or NO (without quotes) to indicate whether there exists a subset whose XOR is equal to ( x ). The output is written to standard output (stdout).## sample

1
3
1 2 3
0
YES