Even OR

0

0 votes
Bit manipulation, Bitmask, Hash function, Greedy Algorithms
Problem

Ashish likes to play with bits. He takes an array of size n and checks that if the array can be converted, such that, bitwise OR of all the array elements after performing the following operation (0 or more times), is even and greater than zero.

  • Choose two indices i, j (1<=i,j<=n) and replace both indices value with a[i]&a[j].

Note: You can't use any of the previously chosen indices in any futher operations i.e., every index can be taken only once.

 

The '&' (bitwise AND)  takes two numbers as operands and does AND on every bit of two numbers. The result of AND is 1 only if both bits are 1.

The '|' (bitwise OR)  takes two numbers as operands and does OR on every bit of two numbers. The result of OR is 1 if any of the two bits is 1.

Input

  • The first line contains an integer T, the number of testcase.
  • The first line of each testcase contains an integer n, the length of the array.
  • The last line of each testcase has n space-separated integers.

Output

Print 'YES', if it is possible else 'NO'.

Constraint

  • 1<=T<=100
  • 1<=N<=105
  • 0<=a[i]<=1015

 

Time Limit: 0.5
Memory Limit: 256
Source Limit:
Explanation

1.In the first test case we can see that one possible array can be formed 2 2 4 4 by choosing 1 and 2 indices, 3 and 4 indices, and taking bitwise i.e (2&3=2),(5&4=4).


2.In the second test case there no possible way because in any way there will be an element(odd number) left such that bitwise or will be odd.
 

Editor Image

?