Max BIT Sum

 Given two arrays 

and each of length

.

Find the value

.
Here and

denote the bitwise XOR operation and bitwise AND operation respectively.

Input Format

  • The first line of input contains a single integer
- the number of test cases. The description of
  • test cases follows.
  • The first line of each test case contains an integer
  • - the length of arrays and
  • .
  • The second line of each test case contains
  • space-separated integers representing the array
  • .
  • The third line of each test case contains
  • space-separated integers representing the array
    • .

    Output Format

    For each test case, output the value

    .

    Constraints

  • Sum of
  • does not exceed
    • over all test cases.

    Sample Input 1

    3
    2
    3 4
    1 2
    1
    0
    0
    3
    2 4 3
    1 2 1
    

    Sample Output 1

    15
    0
    30
    

    Explanation

    • Test Case

    : For the given arrays, the value is:
  • .

  • Test Case

  • : For the given arrays, the value is:
  • .

  • Test Case

  • : For the given arrays, the value is:
    Previous
    Next Post »