#P1515D. Phoenix and Socks

    ID: 5884 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>greedysortingstwo pointers*1500

Phoenix and Socks

No submission language available for this problem.

Description

To satisfy his love of matching socks, Phoenix has brought his nn socks (nn is even) to the sock store. Each of his socks has a color cic_i 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 cc' (1cn)(1 \le c' \le n)
  • 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 n/2n/2 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 tt (1t10001 \le t \le 1000) — the number of test cases.

The first line of each test case contains three integers nn, ll, and rr (2n21052 \le n \le 2 \cdot 10^5; nn is even; 0l,rn0 \le l, r \le n; l+r=nl+r=n) — the total number of socks, and the number of left and right socks, respectively.

The next line contains nn integers cic_i (1cin1 \le c_i \le n) — the colors of the socks. The first ll socks are left socks, while the next rr socks are right socks.

It is guaranteed that the sum of nn across all the test cases will not exceed 21052 \cdot 10^5.

For each test case, print one integer — the minimum cost for Phoenix to make n/2n/2 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 tt (1t10001 \le t \le 1000) — the number of test cases.

The first line of each test case contains three integers nn, ll, and rr (2n21052 \le n \le 2 \cdot 10^5; nn is even; 0l,rn0 \le l, r \le n; l+r=nl+r=n) — the total number of socks, and the number of left and right socks, respectively.

The next line contains nn integers cic_i (1cin1 \le c_i \le n) — the colors of the socks. The first ll socks are left socks, while the next rr socks are right socks.

It is guaranteed that the sum of nn across all the test cases will not exceed 21052 \cdot 10^5.

Output

For each test case, print one integer — the minimum cost for Phoenix to make n/2n/2 matching pairs. Each sock must be included in exactly one matching pair.

Samples

Sample Input 1

4
6 3 3
1 2 3 2 2 2
6 2 4
1 1 2 2 2 2
6 5 1
6 5 4 3 2 1
4 0 4
4 4 4 3

Sample Output 1

2
3
5
3

Note

In the first test case, Phoenix can pay 22 dollars to:

  • recolor sock 11 to color 22
  • recolor sock 33 to color 22
There are now 33 matching pairs. For example, pairs (1,4)(1, 4), (2,5)(2, 5), and (3,6)(3, 6) are matching.

In the second test case, Phoenix can pay 33 dollars to:

  • turn sock 66 from a right sock to a left sock
  • recolor sock 33 to color 11
  • recolor sock 44 to color 11
There are now 33 matching pairs. For example, pairs (1,3)(1, 3), (2,4)(2, 4), and (5,6)(5, 6) are matching.