You are given an array A containing N integers. The ith integer is Ai and has a utility of Bi. You select a combination of integers whose bitwise OR is less than or equal to K.
You are required to make the sum of utilities of selected integers to be as large as possible.
Input format
Output format
For each test case, print the maximum possible sum of utilities of selected integers in a new line.
Constraints
1≤T≤10001≤N≤2000000≤K,Ai,Bi<230
It is guaranteed that the sum of N over T test cases does not exceed 1e6.
For the first testcase, we select A1 and A2, therefore A1|A2=11≤K, and the maximum sum of utilities is 10+14=24.
For the second testcase, we select A1,A2,A3 and A5, therefore A1|A2|A3|A5=11<K, and the maximum sum of utilities is 10+15+9+12=46.