Andor

Time limit: 0.75s Memory limit: 256MB Input: Output:

^

Kasza Andor has received a critical mission from the Rebel Alliance. They have successfully infiltrated the Galactic Empire’s data center and extracted highly classified information about a new weapon of mass destruction. The data is encoded as a sequence of integers V0,...,VN1V_0, . . . , V_{N−1}.

However, the transmission back to the Alliance was made through the Bandwidth Intensive Network for Galactic Universal Service – a notoriously unreliable channel. Due to interference, some integers in the sequence might have been corrupted during transmission.
To verify the integrity of the received data, Andor must apply the following verification procedure:

  • Initialize variable S=0S = 0.
  • For each integer ViV_i in the sequence (in the order they appear), choose and apply exactly one of the following operations:
    • S = S & Vi (bitwise AND).
    • S = S | Vi (bitwise OR).

After processing all elements, the final value of SS is compared against a target value KK. If at least one sequence of choices (using AND/OR per element) leads to S=KS = K, the data is considered valid.

Andor needs your help: Determine whether there exists a sequence of operations that results in a final value of KK.

Input data

The first line of the input file contains a single integer TT, the number of test cases. TT test cases follow.

Each test case consists of:

  • a line containing integers N,KN, K.
  • a line containing the NN integers V0,...,VN1V_0, . . . , V_{N−1}.

Output data

The output file must contain TT lines corresponding to the test cases, each consisting of the string YES if the sequence is valid, or NO otherwise.

Constraints and clarifications

  • 1T501 \leq T \leq 50.
  • 1N100 0001 \leq N \leq 100 \ 000.
  • 0K<2300 \leq K < 2^{30}.
  • 0Vi<2300 \leq V_i < 2^{30} for each i=0,,N1i = 0, \dots, N - 1.
# Score Restrictions
0 0 Examples
1 30 N10,Vi100N \leq 10, V_i \leq 100
2 45 N1 000,Vi1 000N \leq 1 \ 000, V_i \leq 1 \ 000
3 25 No additional limitations.

Example

stdin

3
3 7
1 5 2
5 6
12 11 0 4 2
4 1
3 4 5 6

stdout

YES
YES
NO

Log in or sign up to be able to send submissions!