^
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 .
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 .
- For each integer 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 is compared against a target value . If at least one sequence of choices (using AND/OR per element) leads to , the data is considered valid.
Andor needs your help: Determine whether there exists a sequence of operations that results in a final value of .
Input data
The first line of the input file contains a single integer , the number of test cases. test cases follow.
Each test case consists of:
- a line containing integers .
- a line containing the integers .
Output data
The output file must contain lines corresponding to the test cases, each consisting of the string YES
if the sequence is valid, or NO
otherwise.
Constraints and clarifications
- .
- .
- .
- for each .
# | Score | Restrictions |
---|---|---|
0 | 0 | Examples |
1 | 30 | |
2 | 45 | |
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