Problem: You have an array of integers of length . On the -th of the next days you are going to do exactly one of the following two actions:
- Add to each of the first elements of the array (i.e., set for each ).
- Count the elements which are equal to their position (i.e., the ). Denote the number of such elements as . Then, you add to your score, and reset the entire array to a -array of length (i.e., set ).
Your score is equal to in the beginning. Note that on each day you should perform exactly one of the actions above: you cannot skip a day or perform both actions on the same day.
What is the maximum score you can achieve at the end?
Since can be quite large, the sequence is given to you in the compressed format:
- You are given a sequence of integers . The sequence is a concatenation of infinitely many copies of : .
Input Format: The first line contains a single integer () — the number of test cases.
The first line of each test case contains three integers , and (, , ) — the length of the array , the length of the sequence and the number of days you are going to perform operations on.
The second line of each test case contains integers () — the array .
The third line of each test case contains integers () — the sequence .
It is guaranteed that the sum of over all test cases doesn't exceed and the sum of over all test cases doesn't exceed .
Output Format: For each test case, output one integer: the maximum score you can achieve at the end of the -th day.
Note: In the first test case, the sequence is equal to and one of the optimal solutions for this case is as follows:
- Perform the operation of the second type on the -st day: your score increases by and array becomes equal to .
- Perform the operation of the first type on the -nd day: array becomes equal to .
- Perform the operation of the first type on the -rd day: array becomes equal to .
- Perform the operation of the second type on the -th day: your score increases by and array becomes equal to .
It can be shown that it is impossible to score more than , so the answer is .
In the second test case, the sequence is equal to . One of the ways to score is to perform operations of the first type on the -st and the -rd days and to perform an operation of the second type on the -nd day.