CF1870B.Friendly Arrays
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two arrays of integers — a1,…,an of length n , and b1,…,bm of length m . You can choose any element bj from array b ( 1≤j≤m ), and for all 1≤i≤n perform ai=ai∣bj . You can perform any number of such operations.
After all the operations, the value of x=a1⊕a2⊕…⊕an will be calculated. Find the minimum and maximum values of x that could be obtained after performing any set of operations.
Above, ∣ is the bitwise OR operation, and ⊕ is the bitwise XOR operation.
输入格式
The first line contains a single integer t ( 1≤t≤104 ) — the number of test cases. This is followed by the description of the test cases.
The first line of each test case contains two integers n and m ( 1≤n,m≤2⋅105 ) — the sizes of arrays a and b .
The second line of each test case contains n integers a1,a2,…,an ( 0≤ai≤109 ) — the array a .
The third line of each test case contains m integers b1,b2,…,bm ( 0≤bi≤109 ) — the array b .
It is guaranteed that the sum of values of n and m across all test cases does not exceed 2⋅105 .
输出格式
For each test case, output 2 numbers: the minimum and maximum possible values of x after performing any set of operations.
输入输出样例
输入#1
2 2 3 0 1 1 2 3 3 1 1 1 2 1
输出#1
0 1 2 3
说明/提示
In the first test case, if we apply the operation with element b1=1 , the array a will become [1,1] , and x will be 0 . If no operations are applied, then x=1 .
In the second test case, if no operations are applied, then x=2 . If we apply the operation with b1=1 , then a=[1,1,3] , and x=3 .