#P1941F. Rudolf and Imbalance
Rudolf and Imbalance
Description
Rudolf has prepared a set of problems with complexities . He is not entirely satisfied with the balance, so he wants to add at most one problem to fix it.
For this, Rudolf came up with models of problems and functions. The complexity of the -th model is , and the complexity of the -th function is . To create a problem, he selects values and (, ) and by combining the -th model with the -th function, he obtains a new problem with complexity (a new element is inserted into the array ).
To determine the imbalance of the set, Rudolf sorts the complexities of the problems in ascending order and finds the largest value of ().
What is the minimum value of imbalance that Rudolf can achieve by adding at most one problem, created according to the described rules?
The first line of the input contains a single integer () — the number of testcases.
The first line of each test case contains three integers , , and (, ) — the number of prepared problems, the number of models, and the number of functions, respectively.
The second line of each test case contains integers (, ) — the complexities of the prepared problems.
The third line of each test case contains integers () — the complexities of the models.
The fourth line of each test case contains integers () — the complexities of the functions.
It is guaranteed that the sum of over all testcases does not exceed .
It is guaranteed that the sum of over all testcases does not exceed .
It is guaranteed that the sum of over all testcases does not exceed .
For each testcase, output a single number — the minimum imbalance that Rudolf can achieve.
Input
The first line of the input contains a single integer () — the number of testcases.
The first line of each test case contains three integers , , and (, ) — the number of prepared problems, the number of models, and the number of functions, respectively.
The second line of each test case contains integers (, ) — the complexities of the prepared problems.
The third line of each test case contains integers () — the complexities of the models.
The fourth line of each test case contains integers () — the complexities of the functions.
It is guaranteed that the sum of over all testcases does not exceed .
It is guaranteed that the sum of over all testcases does not exceed .
It is guaranteed that the sum of over all testcases does not exceed .
Output
For each testcase, output a single number — the minimum imbalance that Rudolf can achieve.