#P1721C. Min-Max Array Transformation
Min-Max Array Transformation
Description
You are given an array , which is sorted in non-descending order. You decided to perform the following steps to create array :
- Create an array consisting of arbitrary non-negative integers.
- Set for each .
- Sort the array in non-descending order.
You are given the resulting array . For each index , calculate what is the minimum and maximum possible value of you can choose in order to get the given array .
Note that the minimum (maximum) -s are independent of each other, i. e. they can be obtained from different possible arrays .
The first line contains the single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of arrays , and .
The second line contains integers (; ) — the array in non-descending order.
The third line contains integers (; ) — the array in non-descending order.
Additional constraints on the input:
- there is at least one way to obtain the array from the by choosing an array consisting of non-negative integers;
- the sum of doesn't exceed .
For each test case, print two lines. In the first line, print integers , where is the minimum possible value you can add to .
Secondly, print integers , where is the maximum possible value you can add to .
All and values are independent of each other. In other words, for each , is just the minimum value among all possible values of .
Input
The first line contains the single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of arrays , and .
The second line contains integers (; ) — the array in non-descending order.
The third line contains integers (; ) — the array in non-descending order.
Additional constraints on the input:
- there is at least one way to obtain the array from the by choosing an array consisting of non-negative integers;
- the sum of doesn't exceed .
Output
For each test case, print two lines. In the first line, print integers , where is the minimum possible value you can add to .
Secondly, print integers , where is the maximum possible value you can add to .
All and values are independent of each other. In other words, for each , is just the minimum value among all possible values of .
Note
In the first test case, in order to get , we can choose, for example, . Then .
For , we can choose . Then .