#P9876. M. Minimal and Maximal XOR Sum
M. Minimal and Maximal XOR Sum
M. Minimal and Maximal XOR Sum
Problem Description
Given a permutation of . You can perform several operations. In each operation you can choose an interval and reverse the elements to , the weight of this operation is . You can perform any number of operations, and your goal is to make at last. Please calculate the minimal and maximal XOR sum of the weight of all the operations.
Input
The input consists of multiple test cases. The first line contains a single integer () - the number of test cases. Description of the test cases follows. The first line of each test case contains one integer (). The second line contains integers . It's guaranteed that .
Output
For each test case, print two integers - the minimal and maximal XOR sum of the weight of all the operations.
Sample Input
3
3
1 3 2
3
3 1 2
6
1 2 5 6 3 4
Sample Output
2 3
0 1
0 5
Source
2023“钉耙编程”中国大学生算法设计超级联赛(7)