#P1770A. Koxia and Whiteboards
Koxia and Whiteboards
Description
Kiyora has whiteboards numbered from to . Initially, the -th whiteboard has the integer written on it.
Koxia performs operations. The -th operation is to choose one of the whiteboards and change the integer written on it to .
Find the maximum possible sum of integers written on the whiteboards after performing all operations.
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains two integers and ().
The second line of each test case contains integers ().
The third line of each test case contains integers ().
For each test case, output a single integer — the maximum possible sum of integers written on whiteboards after performing all operations.
Input
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains two integers and ().
The second line of each test case contains integers ().
The third line of each test case contains integers ().
Output
For each test case, output a single integer — the maximum possible sum of integers written on whiteboards after performing all operations.
Note
In the first test case, Koxia can perform the operations as follows:
- Choose the -st whiteboard and rewrite the integer written on it to .
- Choose the -nd whiteboard and rewrite to .
After performing all operations, the numbers on the three whiteboards are , and respectively, and their sum is . It can be proven that this is the maximum possible sum achievable.
In the second test case, Koxia can perform the operations as follows:
- Choose the -nd whiteboard and rewrite to .
- Choose the -st whiteboard and rewrite to .
- Choose the -nd whiteboard and rewrite to .
The sum is . It can be proven that this is the maximum possible sum achievable.