#P1515D. Phoenix and Socks
Phoenix and Socks
No submission language available for this problem.
Description
To satisfy his love of matching socks, Phoenix has brought his socks ( is even) to the sock store. Each of his socks has a color and is either a left sock or right sock.
Phoenix can pay one dollar to the sock store to either:
- recolor a sock to any color
- turn a left sock into a right sock
- turn a right sock into a left sock
The sock store may perform each of these changes any number of times. Note that the color of a left sock doesn't change when it turns into a right sock, and vice versa.
A matching pair of socks is a left and right sock with the same color. What is the minimum cost for Phoenix to make matching pairs? Each sock must be included in exactly one matching pair.
The input consists of multiple test cases. The first line contains an integer () — the number of test cases.
The first line of each test case contains three integers , , and (; is even; ; ) — the total number of socks, and the number of left and right socks, respectively.
The next line contains integers () — the colors of the socks. The first socks are left socks, while the next socks are right socks.
It is guaranteed that the sum of across all the test cases will not exceed .
For each test case, print one integer — the minimum cost for Phoenix to make matching pairs. Each sock must be included in exactly one matching pair.
Input
The input consists of multiple test cases. The first line contains an integer () — the number of test cases.
The first line of each test case contains three integers , , and (; is even; ; ) — the total number of socks, and the number of left and right socks, respectively.
The next line contains integers () — the colors of the socks. The first socks are left socks, while the next socks are right socks.
It is guaranteed that the sum of across all the test cases will not exceed .
Output
For each test case, print one integer — the minimum cost for Phoenix to make matching pairs. Each sock must be included in exactly one matching pair.
Samples
Note
In the first test case, Phoenix can pay dollars to:
- recolor sock to color
- recolor sock to color
In the second test case, Phoenix can pay dollars to:
- turn sock from a right sock to a left sock
- recolor sock to color
- recolor sock to color