#P1775B. Gardener and the Array
Gardener and the Array
Description
The gardener Kazimir Kazimirovich has an array of integers .
He wants to check if there are two different subsequences and of the original array, for which , where is the bitwise OR of all of the numbers in the sequence .
A sequence is a subsequence of if can be obtained from by deleting several (possibly none or all) elements.
Two subsequences are considered different if the sets of indexes of their elements in the original sequence are different, that is, the values of the elements are not considered when comparing the subsequences.
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains one integer () — the size of the array .
The description of the array in this problem is given implicitly to speed up input.
The -st of the following lines of the test case begins with an integer () — the number of set bits in the number . Next follow distinct integers () —the numbers of bits that are set to one in number . In other words, .
It is guaranteed that the total sum of in all tests does not exceed .
For each set of input, print "Yes" if there exist two different subsequences for which , and "No" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains one integer () — the size of the array .
The description of the array in this problem is given implicitly to speed up input.
The -st of the following lines of the test case begins with an integer () — the number of set bits in the number . Next follow distinct integers () —the numbers of bits that are set to one in number . In other words, .
It is guaranteed that the total sum of in all tests does not exceed .
Output
For each set of input, print "Yes" if there exist two different subsequences for which , and "No" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
Note
It can be proven that in the first test case there are no two different subsequences and for which .
In the second test case, one of the possible answers are following subsequences: the subsequence formed by the element at position , and the subsequence formed by the elements at positions and .
In the third test case, one of the possible answers are following subsequences: the subsequence formed by elements at positions , , and , and the subsequence formed by elements at positions , and .