You are given two integer arrays and of length and respectively. You can do the following operations on array .
Remove one element from . This operation can be performed at most times.
Insert any element of into at any position. You can insert each element of at most once.
Output the maximum possible value of that you can achieve after performing the aforementioned operations.
Input starts with an integer , denoting the number of test cases. In each test case,
The first line contains integers and .
The second line contains integers .
The third line contains integers .
Constraints:
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print the maximum possible value of .
Input | Output |
---|---|
1 6 5 2 100 -10 20 -2000000 -5 500 -4 -5 -1 -2 70 | 6147 |
In the first test case, we shall perform the following operations:
After completing those operations sequentially, array A gives the maximum result. |
Input | Output |
---|---|
5 4 1 1 -160 -290 -693 -597 38 2 2 3 -149 990 46 48 4 6 2 475 -164 -170 456 59 11 26 -45 -76 -65 6 4 4 997 -711 871 251 617 -306 84 -84 -20 -31 1 5 1 298 -98 -9 -1 -95 -87 | -2379 4047 7160 17034 1198 |