Statement
Statement language
There are two integer sequences and , each of length . The sequence satisfies . For , define .
Choose a sequence of integers such that and
Find the maximum possible value of
If , no element is taken from column .
Input
The input is given in the following format:
Each case is given in the following format:
Output
For each test case, print the maximum possible value on one line.
Constraints
- ()
- The sum of over all test cases does not exceed .
Subtasks
Samples
Input
2
3 4
5 2 1
0 4 -1
2 0
3 1
7 8
Output
25
0