Very Tough Question

5

2 votes
Easy
Problem

STATEMENT

You are given a number A and an array S with N numbers. Your job is to find a non empty sub set of S such that the Bitwise AND (&) of the given number A and this subset is zero.
If such set is possible print “YES” otherwise print “NO”.

INPUT

First line contains number of test cases T. Each test case contains two lines, first line contains two numbers A and N, where A is the given number and N is the size of array. Second line contains N elements of the array S.

OUTPUT

For each test case output “YES” or “NO” in new line.

CONSTRAINTS

1<=T<=105
1<=N<=50
1<=A<=100
0<=Si<=100

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In first test case, the subset {2,1} satisfies the condition.
In second test case, no subset satisfies the condition.

Editor Image

?