题目描述
Chef found N magical cards in his drawer. Each card has a number written on each of its faces. He places all the cards on the table in a front face-up manner.
Chef denotes the numbers on the front face by A_{1}, A_{2},..., A_{N} and on the back face by B_{1}, B_{2},..., B_{N}. Chef can choose some (possibly zero or all) cards and flip them, then he will calculate the [bitwise AND] of all the numbers currently in a face-up manner.
Now Chef wonders what is the maximum bitwise AND that he can achieve and what is the minimum number of cards he has to flip to achieve this value. Can you help him find it?
------ Input Format ------
- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- Each test case contains three lines of input.
- The first line contains a single integer N - the number of cards.
- The second line contains N space-separated integers A_{1}, A_{2},..., A_{N} - the numbers on the front face of the cards
- The third line contains N space-separated integers B_{1}, B_{2},..., B_{N} - the numbers on the back face of the cards
------ Output Format ------
For each test case, print a single line containing two space-separated integers, first denoting the maximum bitwise AND possible and second denoting the minimum number of flips required to achieve it.
------ Constraints ------
$1 ≤ T ≤ 10^{4}$
$1 ≤ N ≤ 10^{5}$
$0 ≤ A_{i} ≤ 2^{30} - 1$
$0 ≤ B_{i} ≤ 2^{30} - 1$
- Sum of $N$ over all testcases does not exceeds $10^{5}$.
----- Sample Input 1 ------
3
3
4 6 8
2 1 2
3
0 2 0
2 0 8
3
1 2 1
2 3 6
----- Sample Output 1 ------
2 2
0 0
2 2
----- explanation 1 ------
Test case $1$: The maximum AND is obtained after flipping the first and third cards achieving a configuration of $[2, 6, 2]$ which yields a bitwise AND of $2$.
Test case $2$: Every possible configuration of the cards yields a bitwise AND equal to $0$. So to ensure the minimum number of operations, Chef performs no flip.
输入格式
见题面
输出格式
见题面