#P1914C. Quests
Quests
No submission language available for this problem.
Description
Monocarp is playing a computer game. In order to level up his character, he can complete quests. There are quests in the game, numbered from to .
Monocarp can complete quests according to the following rules:
- the -st quest is always available for completion;
- the -th quest is available for completion if all quests have been completed at least once.
Note that Monocarp can complete the same quest multiple times.
For each completion, the character gets some amount of experience points:
- for the first completion of the -th quest, he gets experience points;
- for each subsequent completion of the -th quest, he gets experience points.
Monocarp is a very busy person, so he has free time to complete no more than quests. Your task is to calculate the maximum possible total experience Monocarp can get if he can complete no more than quests.
The first line contains a single integer () — the number of test cases.
The first line of each test case contains two integers and (; ) — the number of quests and the maximum number of quests Monocarp can complete, respectively.
The second line contains integers ().
The third line contains integers ().
Additional constraint on the input: the sum of over all test cases does not exceed .
For each test case, print a single integer — the maximum possible total experience Monocarp can get if he can complete no more than quests.
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains two integers and (; ) — the number of quests and the maximum number of quests Monocarp can complete, respectively.
The second line contains integers ().
The third line contains integers ().
Additional constraint on the input: the sum of over all test cases does not exceed .
Output
For each test case, print a single integer — the maximum possible total experience Monocarp can get if he can complete no more than quests.
Note
In the first test case, one of the possible quest completion sequences is as follows: ; its total experience is equal to (the underlined numbers correspond to the instances when we complete a quest for the first time).
In the second test case, one of the possible quest completion sequences is as follows: ; its total experience is equal to .
In the third test case, one of the possible quest completion sequences is as follows: ; its total experience is equal to .