Breaking news! Contestant Andu from Iași has announced that he will not attend the IIOT finals because the Copou Grand Prix will take place at the same time as the contest.
The Grand Prix consists of races in which drivers compete, two of whom are Alice and Bob. We know that Alice finished the races in positions , and Bob in positions .
Task
Because defeat is inevitable, Andu wants to assign the number of points awarded for each finishing position () in such a way that the following conditions are met:
- , where is a given positive integer.
- The value is maximized.
Once assigned, the points are the same for all races. Your task is to find the maximum possible value of .
Input data
The first line of the input contains an integer , representing the number of test cases. Each test case is described as follows:
- The first line contains three space-separated integers, , , and , where is the number of races, is the number of drivers, and is the maximum number of points awarded for finishing in first place.
- The second line contains space-separated integers, , representing the Alices's finishing positions in each race.
- The third line contains space-separated integers, , representing the Bob's finishing positions in each race.
Output data
For each test case, you must output the maximum value achievable for on a separate line.
Constraints and clarifications
- The sum of over all test cases will not exceed .
- , for every
| # | Score | Constraints |
|---|---|---|
| 0 | 0 | Examples |
| 1 | 6 | |
| 2 | 11 | |
| 3 | 38 | ; |
| 4 | 25 | The sum of over all test cases will not exceed . |
| 5 | 16 | No further restrictions. |
Example
stdin
6
6 5 5
1 1 3 3 3 5
1 2 2 3 4 5
8 12 15
1 1 2 2 3 3 6 11
1 2 2 3 5 5 7 9
8 12 15
1 2 2 3 5 5 7 9
1 1 2 2 3 3 6 11
4 8 10
5 6 7 8
1 2 3 4
6 6 5
1 2 3 4 5 6
1 2 3 4 5 6
10 6 6
2 3 3 3 4 4 6 6 6 6
2 2 2 3 3 4 4 4 5 6
stdout
2
13
-1
-19
0
-8
Explanation
In the first test case, the optimal number of points awarded for each position (with regard to maximizing ) is .
For this point distribution, .
In the second test case, an optimal point distribution is .