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

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

The next line contains $n$ integers $c_i$ ($1 \le c_i \le n$) — the colors of the socks. The first $l$ socks are left socks, while the next $r$ socks are right socks.

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


-----Output-----

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


-----Examples-----

Input
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
Output
2
3
5
3


-----Note-----

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

recolor sock $1$ to color $2$

recolor sock $3$ to color $2$

There are now $3$ matching pairs. For example, pairs $(1, 4)$, $(2, 5)$, and $(3, 6)$ are matching.

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

turn sock $6$ from a right sock to a left sock

recolor sock $3$ to color $1$

recolor sock $4$ to color $1$

There are now $3$ matching pairs. For example, pairs $(1, 3)$, $(2, 4)$, and $(5, 6)$ are matching.

Source: codeforces | Difficulty: MEDIUM
Tags: Sorting

Amortized analysis

Greedy algorithms


Solutions:
import sys
input = sys.stdin.readline

def inI():
	inputLine = input().split()
	return int(inputLine[0]) if len(inputLine) == 1 else map(int, inputLine)

def inIL():
	return list(map(int, input().split()))

def inCL():
	return list(input())[:-1]

def out(*liste):
	if isinstance(liste[0], list):
		liste = liste[0]
	for element in liste:
		print(element, end=' ')
	print()
t = inI()
for it in range(t):
	(n, l, r) = inI()
	socks = inIL()
	(left, right) = (socks[:l], socks[l:])
	if l < r:
		(left, right) = (right, left)
		(r, l) = (l, r)
	nbleft = [0] * (n + 1)
	sumleft = l
	nbright = [0] * (n + 1)
	sumright = r
	for color in left:
		nbleft[color] += 1
	for color in right:
		nbright[color] += 1
	for color in range(1, n + 1):
		paired = min(nbleft[color], nbright[color])
		nbleft[color] -= paired
		sumleft -= paired
		nbright[color] -= paired
		sumright -= paired
	nbop = 0
	for color in range(1, n + 1):
		if sumleft <= sumright:
			break
		switch = min(nbleft[color] // 2, (sumleft - sumright) // 2)
		nbop += switch
		nbleft[color] -= 2 * switch
		sumleft -= 2 * switch
	nbop += sumleft
	print(nbop)


from collections import defaultdict

def solve():
	(n, l, r) = map(int, input().split())
	a = list(map(int, input().split()))
	ls = defaultdict(int)
	rs = defaultdict(int)
	for i in range(n):
		if i < l:
			ls[a[i]] += 1
		else:
			rs[a[i]] += 1
	ans = 0
	for (i, j) in ls.items():
		mino = min(j, rs[i])
		ls[i] -= mino
		rs[i] -= mino
	tl = 0
	tr = 0
	for e in ls.values():
		tl += e
	for e in rs.values():
		tr += e
	if tl <= tr:
		more = tr - tl
		for (i, j) in rs.items():
			if more <= 0:
				break
			while more > 0 and j >= 2:
				j -= 2
				tr -= 2
				ans += 1
				more -= 2
		ans += tl + more
	else:
		more = tl - tr
		for (i, j) in ls.items():
			if more <= 0:
				break
			while more > 0 and j >= 2:
				j -= 2
				tl -= 2
				ans += 1
				more -= 2
		ans += tr + more
	print(ans)
test = int(input())
for _ in range(test):
	solve()


total = 6
left = 3
right = 3
arr = [1, 2, 3, 1, 5, 6]

def answer(total, left, right, arr):
	dp_left = [0 for i in range(total)]
	dp_right = [0 for i in range(total)]
	i = 0
	while i < left:
		dp_left[arr[i] - 1] += 1
		i += 1
	while i < len(arr):
		dp_right[arr[i] - 1] += 1
		i += 1
	left1 = 0
	right1 = 0
	for i in range(total):
		if dp_left[i] >= 1 and dp_right[i] >= 1:
			m = min(dp_left[i], dp_right[i])
			dp_left[i] -= m
			dp_right[i] -= m
			left1 += dp_left[i]
			right1 += dp_right[i]
		else:
			left1 += dp_left[i]
			right1 += dp_right[i]
	cost = 0
	mid = (left1 + right1) // 2
	if left1 > mid:
		cost += left1 - mid
		for i in range(total):
			if dp_left[i] >= 2:
				k = dp_left[i] // 2
				if left1 - 2 * k > right1:
					left1 -= 2 * k
				elif left1 - 2 * k == right1:
					left1 -= 2 * k
					break
				else:
					p = right1 - (left1 - 2 * k)
					left1 -= p
					break
	if right1 > mid:
		cost += right1 - mid
		for i in range(total):
			if dp_right[i] >= 2:
				k = dp_right[i] // 2
				if right1 - 2 * k > left1:
					right1 -= 2 * k
				elif right1 - 2 * k == left1:
					right1 -= 2 * k
					break
				else:
					p = left1 - (right1 - 2 * k)
					right1 -= p
					break
	cost += (left1 + right1) // 2
	print(cost)
t = int(input())
for w in range(t):
	inp = input().split()
	total = int(inp[0])
	left = int(inp[1])
	right = int(inp[2])
	inp = input().split()
	arr = []
	for i in inp:
		arr.append(int(i))
	answer(total, left, right, arr)


for i in range(int(input())):
	(n, l, r) = map(int, input().split())
	C = [int(i) for i in input().split()]
	(cost, cost1, cost2) = (0, 0, 0)
	C1 = C[:l]
	C2 = C[l:]
	(d1, d2) = (dict(), dict())
	for i in C1:
		if i in d1:
			d1[i] += 1
		else:
			d1[i] = 1
	for j in C2:
		if j in d2:
			d2[j] += 1
		else:
			d2[j] = 1
	for i in d1:
		if i in d2:
			x1 = d1[i]
			x2 = d2[i]
			sub = min(x1, x2)
			d1[i] = x1 - sub
			d2[i] = x2 - sub
	(sum1, sum2) = (0, 0)
	(d1_1, d1_pair) = (0, 0)
	for i in d1:
		sum1 += d1[i]
		if d1[i] == 1:
			d1_1 += 1
		else:
			d1_pair += d1[i] - d1[i] % 2
			d1_1 += d1[i] % 2
	(d2_1, d2_pair) = (0, 0)
	for i in d2:
		sum2 += d2[i]
		if d2[i] == 1:
			d2_1 += 1
		else:
			d2_pair += d2[i] - d2[i] % 2
			d2_1 += d2[i] % 2
	rem = abs(sum1 - sum2)
	costa = min(sum1, sum2)
	if sum1 > sum2:
		if d1_pair >= rem:
			costa += rem / 2
		else:
			ref = rem - d1_pair
			costa += d1_pair / 2
			costa += ref
	elif sum1 < sum2:
		if d2_pair >= rem:
			costa += rem / 2
		else:
			ref = rem - d2_pair
			costa += d2_pair / 2
			costa += ref
	print(int(costa))


from sys import stdin, stdout
input = stdin.readline

def im():
	return map(int, input().split())

def ii():
	return int(input())

def il():
	return list(map(int, input().split()))

def ins():
	return input()[:-1]
for _ in range(ii()):
	(n, l, r) = im()
	lis = il()
	left = lis[:l]
	right = lis[l:]
	ldic = [0] * (n + 1)
	rdic = [0] * (n + 1)
	for i in left:
		ldic[i] += 1
	for i in right:
		rdic[i] += 1
	for i in left:
		if ldic[i] > 0 and rdic[i] > 0:
			mi = min(ldic[i], rdic[i])
			ldic[i] -= mi
			rdic[i] -= mi
			l -= mi
			r -= mi
	count = 0
	while True:
		if l == r:
			stdout.write(str(count + l) + '\n')
			break
		elif l < r:
			flag = 0
			for i in range(len(rdic)):
				if rdic[i] > 1:
					cnt = min(rdic[i] // 2, (r - l) // 2)
					rdic[i] -= cnt * 2
					count += cnt
					r -= cnt * 2
					flag = 1
					if l == r:
						break
			if flag == 0:
				cnt = (r - l) // 2
				count += cnt
				l += cnt
				r -= cnt
		else:
			flag = 0
			for i in range(len(ldic)):
				if ldic[i] > 1:
					cnt = min(ldic[i] // 2, (l - r) // 2)
					ldic[i] -= cnt * 2
					count += cnt
					l -= cnt * 2
					flag = 1
					if l == r:
						break
			if flag == 0:
				cnt = (l - r) // 2
				count += cnt
				r += cnt
				l -= cnt


import math
t = int(input())
for t in range(t):
	(n, l, r) = map(int, input().split())
	lst = list(map(int, input().split()))
	lft = lst[0:l]
	rgt = lst[l:]
	d1 = {}
	d2 = {}
	lc = l
	rc = r
	for i in lft:
		d1[i] = d1.get(i, 0) + 1
	for i in rgt:
		d2[i] = d2.get(i, 0) + 1
	c = 0
	for (k, v) in d1.items():
		if d2.get(k, 0) != 0:
			m = min(d1[k], d2[k])
			d1[k] = d1[k] - m
			d2[k] = d2[k] - m
			lc = lc - m
			rc = rc - m
	c = 0
	v1 = list(d1.values())
	v2 = list(d2.values())
	z = lc - rc
	z = z // 2
	if z == 0:
		c = lc
	elif z < 0:
		z = abs(z)
		for i in range(len(v2)):
			if z > 0:
				if v2[i] > 1:
					d = v2[i] // 2
					if d < z:
						c = c + d
						v2[i] = v2[i] - 2 * d
						z = z - d
					else:
						c = c + z
						v2[i] = v2[i] - 2 * z
						z = 0
			else:
				break
		s = sum(v1) + sum(v2)
		c = c + s // 2 + z
	else:
		z = abs(z)
		for i in range(len(v1)):
			if z > 0:
				if v1[i] > 1:
					d = v1[i] // 2
					if d < z:
						c = c + d
						v1[i] = v1[i] - 2 * d
						z = z - d
					else:
						c = c + z
						v1[i] = v1[i] - 2 * z
						z = 0
			else:
				break
		s = sum(v1) + sum(v2)
		c = c + s // 2 + z
	print(c)


from collections import Counter
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	arr = list(map(int, input().split()))
	if r > l:
		left = arr[l:]
		right = arr[:l]
	else:
		left = arr[:l]
		right = arr[l:]
	leftcount = Counter(left)
	rightcount = Counter(right)
	result = 0
	for (key, value) in leftcount.items():
		rightval = rightcount[key]
		mini = min(rightval, value)
		rightcount[key] -= mini
		leftcount[key] -= mini
	difff = abs(l - r) // 2
	litems = 0
	ritems = 0
	for (key, value) in leftcount.items():
		pairs = value // 2
		mini = min(difff, pairs)
		result += mini
		leftcount[key] -= mini * 2
		difff -= mini
		if difff < 1:
			break
	for i in leftcount.values():
		litems += i
	for j in rightcount.values():
		ritems += j
	oneside = (litems + ritems) // 2
	result += abs(litems - ritems) // 2
	result += oneside
	print(result)


from sys import *
ws = lambda : map(int, stdin.readline().strip().split())
li = lambda : list(map(int, stdin.readline().strip().split()))
mod = 1000000007

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def prod(l):
	ans = 1
	for i in range(len(l)):
		ans = ans * l[i]
	return ans

def sortindex(l, a):
	c = []
	if a == -1:
		rev = True
	else:
		rev = False
	for i in range(len(l)):
		c.append([l[i], i])
	x = sorted(c, reverse=rev)
	return x
for _ in range(int(input())):
	(n, le, rr) = ws()
	lis = li()
	l = [0] * (n + 1)
	r = [0] * (n + 1)
	for i in range(n):
		if i < le:
			l[lis[i]] += 1
		else:
			r[lis[i]] += 1
	temp = n // 2 - min(le, rr)
	ans = temp
	matches = 0
	if le > rr:
		for i in range(n + 1):
			if temp == 0:
				break
			if l[i] > r[i]:
				c = (l[i] + r[i]) // 2 - r[i]
				if c == 0:
					continue
				if c <= temp:
					temp -= c
					l[i] -= c
					r[i] += c
				else:
					l[i] -= temp
					r[i] += temp
					temp = 0
	elif rr > le:
		for i in range(n + 1):
			if temp == 0:
				break
			if r[i] > l[i]:
				c = (l[i] + r[i]) // 2 - l[i]
				if c == 0:
					continue
				if c <= temp:
					temp -= c
					l[i] += c
					r[i] -= c
				else:
					l[i] += temp
					r[i] -= temp
					temp = 0
	for i in range(n + 1):
		if l[i] != 0 and r[i] != 0:
			matches += min(l[i], r[i])
	ans += n // 2 - matches
	print(ans)


import sys
from typing import Counter

def solve(a, l, r):
	left = Counter(a[:l])
	right = Counter(a[l:])
	money = 0
	for k in left:
		if k in right:
			s = min(left[k], right[k])
			left[k] -= s
			right[k] -= s
			l -= s
			r -= s
	if l == r:
		return l
	if l > r:
		(left, right) = (right, left)
		(l, r) = (r, l)
	delta = r - l
	for k in right:
		v = right[k]
		t = v - v % 2
		if t < delta:
			delta -= t
			money += t // 2
			right[k] -= t
		else:
			return money + delta // 2 + l
	return money + l + delta

def main():
	input = sys.stdin.readline
	print = sys.stdout.write
	res = ''
	t = int(input())
	for _ in range(t):
		(_, l, r) = map(int, input().split())
		a = list(map(int, input().split()))
		sub_res = solve(a, l, r)
		res += str(sub_res) + '\n'
	print(res)
main()


for _ in range(int(input())):
	(n, l, r) = list(map(int, input().split()))
	ar = list(map(int, input().split()))
	(rem, a, b) = (n, [0] * (n + 1), [0] * (n + 1))
	for i in range(l):
		a[ar[i]] += 1
	for i in range(l, n):
		b[ar[i]] += 1
	for i in range(1, n + 1):
		x = min(a[i], b[i])
		(a[i], b[i]) = (a[i] - x, b[i] - x)
		rem -= 2 * x
	if r < l:
		(l, r) = (r, l)
		(a, b) = (b, a)
	(mx, t) = (sum([b[i] // 2 for i in range(1, n + 1)]), (r - l) // 2)
	print((rem - 2 * min(t, mx)) // 2 + t)


t = int(input())
for _ in range(t):
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	colors = [[0] * 2 for _ in range(n)]
	cost = 0
	L = c[:l]
	R = c[l:]
	for i in L:
		if colors[i - 1][1] > 0:
			colors[i - 1][1] -= 1
		else:
			colors[i - 1][0] += 1
	for i in R:
		if colors[i - 1][0] > 0:
			colors[i - 1][0] -= 1
		else:
			colors[i - 1][1] += 1
	lpair = 0
	rpair = 0
	for i in range(n):
		lpair += colors[i][0] // 2
		rpair += colors[i][1] // 2
	lcnt = 0
	rcnt = 0
	for i in range(n):
		if colors[i][0]:
			lcnt += colors[i][0]
		if colors[i][1]:
			rcnt += colors[i][1]
	cost += min(rcnt, lcnt)
	if rcnt == lcnt:
		print(cost)
		continue
	v = max(rcnt, lcnt)
	diff = abs(rcnt - lcnt)
	if v == lcnt:
		if lpair * 2 >= diff:
			cost += diff // 2
		else:
			cost += diff - lpair
	elif rpair * 2 >= diff:
		cost += diff // 2
	else:
		cost += diff - rpair
	print(cost)


t = int(input())
for _ in range(t):
	(n, l, r) = map(int, input().split())
	C = list(map(int, input().split()))
	d = {}
	for i in range(1, n + 1):
		d.update({i: [0, 0]})
	for i in range(l):
		d[C[i]][0] += 1
	for i in range(l, n):
		d[C[i]][1] += 1
	c = n // 2 - min(l, r)
	s = 0
	for i in d:
		x = (d[i][1] + d[i][0]) // 2 - min(d[i])
		if s + x <= c:
			if d[i][0] <= d[i][1] and l <= r:
				d[i][0] += x
				d[i][1] -= x
				s += x
			elif d[i][0] > d[i][1] and l > r:
				d[i][0] -= x
				d[i][1] += x
				s += x
		elif d[i][0] <= d[i][1] and l <= r:
			d[i][0] += c - s
			d[i][1] -= c - s
			s = c
		elif d[i][0] > d[i][1] and l > r:
			d[i][0] -= c - s
			d[i][1] += c - s
			s = c
	if s < c:
		for i in d:
			if s == c:
				break
			if l < r and d[i][0] < d[i][1]:
				(d[i][0], d[i][1]) = (d[i][1], d[i][0])
				s += 1
			elif l > r and d[i][0] > d[i][1]:
				(d[i][0], d[i][1]) = (d[i][1], d[i][0])
				s += 1
	for i in d:
		if d[i][0] > d[i][1]:
			c += d[i][0] - d[i][1]
	print(c)


t = int(input())
for i in range(t):
	(n, l, r) = [int(x) for x in input().split()]
	lis = [int(x) for x in input().split()]
	dict1 = dict()
	dict2 = dict()
	for i in range(l):
		dict1[lis[i]] = dict1.get(lis[i], 0) + 1
	for i in range(l, r + l):
		if lis[i] in dict1 and dict1[lis[i]] > 0:
			dict1[lis[i]] -= 1
		else:
			dict2[lis[i]] = dict2.get(lis[i], 0) + 1
	cost = 0
	sum_left = sum([x for x in dict1.values()])
	sum_right = sum([x for x in dict2.values()])
	if sum_left == sum_right:
		print(sum_left)
	elif sum_left > sum_right:
		max_2 = sum([x // 2 for x in dict1.values()])
		if max_2 * 2 >= sum_left - sum_right:
			print(sum_right + (sum_left - sum_right) // 2)
		else:
			print(max_2 + sum_right + (sum_left - sum_right - max_2 * 2))
	else:
		max_2 = sum([x // 2 for x in dict2.values()])
		if max_2 * 2 >= sum_right - sum_left:
			print(sum_left + (sum_right - sum_left) // 2)
		else:
			print(max_2 + sum_left + (sum_right - sum_left - max_2 * 2))


def main():
	(n, l, r) = map(int, input().split())
	k = n // 2
	c = list(map(int, input().split()))
	(c1, c2) = (c[:l], c[l:])
	delta = abs(r - l) // 2
	(p1, p2) = ([0] * n, [0] * n)
	for i in range(l):
		p1[c1[i] - 1] += 1
	for i in range(r):
		p2[c2[i] - 1] += 1
	ans = 0
	for i in range(n):
		while p1[i] > 0 and p2[i] > 0:
			p1[i] -= 1
			p2[i] -= 1
			k -= 1
	if l > r:
		for i in range(n):
			while p1[i] >= 2 and delta > 0:
				delta -= 1
				p1[i] -= 2
				k -= 1
				ans += 1
	elif l < r:
		for i in range(n):
			while p2[i] >= 2 and delta > 0:
				delta -= 1
				p2[i] -= 2
				k -= 1
				ans += 1
	if delta != 0:
		ans += delta * 2
		k -= delta
	ans += k
	print(ans)
for _ in range(int(input())):
	main()


for z in range(int(input())):
	(n, l, r) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	dl = {}
	dr = {}
	for i in range(l):
		if arr[i] not in dl:
			dl[arr[i]] = []
		dl[arr[i]].append(i)
	for i in range(l, n):
		if arr[i] not in dr:
			dr[arr[i]] = []
		dr[arr[i]].append(i)
	templ = n - r
	tempr = n - l
	for i in range(l):
		if arr[i] in dr:
			templ -= 1
			tempr -= 1
			temp1 = dl[arr[i]]
			temp2 = dr[arr[i]]
			del temp1[0]
			del temp2[0]
			if len(temp1) == 0:
				del dl[arr[i]]
			else:
				dl[arr[i]] = temp1
			if len(temp2) == 0:
				del dr[arr[i]]
			else:
				dr[arr[i]] = temp2
	ans = 0
	if templ > tempr:
		for i in dl:
			tem = dl[i]
			while len(tem) >= 2 and templ > tempr:
				del tem[0]
				del tem[0]
				templ -= 2
				ans += 1
		if templ > tempr:
			ans += templ - tempr
			templ = tempr
	else:
		for i in dr:
			tem = dr[i]
			while len(tem) >= 2 and tempr > templ:
				del tem[0]
				del tem[0]
				tempr -= 2
				ans += 1
		if tempr > templ:
			ans += tempr - templ
			tempr = templ
	ans += templ
	print(ans)


import string
from collections import deque, Counter
DEBUG = 0

def main():
	T = Input.read_typed(int)[0]
	while T:
		(n, lc, rc) = Input.read_typed(int)
		socks = Input.read_typed(int)
		cost = 0
		cset = set(socks)
		l = Counter(socks[:lc])
		r = Counter(socks[-rc:]) if rc != 0 else Counter()
		for c in cset:
			paired = min(l[c], r[c])
			l[c] -= paired
			r[c] -= paired
		l_left = sum(l.values())
		r_left = sum(r.values())
		if l_left > r_left:
			(l, r, l_left, r_left) = (r, l, r_left, l_left)
		if l_left < r_left:
			r_twins = sum((r[c] // 2 for c in cset))
			take = min(r_twins, (r_left - l_left) // 2)
			cost += take
			r_left -= take * 2
			take = (r_left - l_left) // 2
			cost += take
			l_left += take
			r_left -= take
		assert l_left == r_left
		cost += l_left
		print(cost)
		T -= 1

class Input:

	def __init__(self):
		pass

	@staticmethod
	def read_typed(cls):
		return list(map(cls, input().split()))

	@staticmethod
	def read():
		return input()

class Debug:

	def __init__(self):
		import sys
		sys.stdout = open('output.out', 'w')
		sys.stdin = open('input.in', 'r')

	def __delete__(self):
		sys.stdout.close()
		sys.stdin.close()

def run():
	if DEBUG:
		_ = Debug()
	main()
run()


from collections import defaultdict
t = int(input())
while t != 0:
	(n, l, r) = map(int, input().split())
	list1 = list(map(int, input().split()))
	d1 = defaultdict(int)
	d2 = defaultdict(int)
	for i in range(l):
		d1[list1[i]] += 1
	for i in range(l, n):
		d2[list1[i]] += 1
	for i in d2.keys():
		mini = min(d1[i], d2[i])
		d1[i] -= mini
		d2[i] -= mini
	ans = 0
	diff = abs(l - r) // 2
	p1 = sum(d1.values())
	p2 = sum(d2.values())
	if p1 > p2:
		for i in d1.keys():
			p = d1[i] // 2
			mini = min(p, diff)
			d1[i] -= mini * 2
			diff -= mini
			ans += mini
			if diff == 0:
				break
	else:
		for i in d2.keys():
			p = d2[i] // 2
			mini = min(p, diff)
			d2[i] -= mini * 2
			diff -= mini
			ans += mini
			if diff == 0:
				break
	p1 = sum(d1.values())
	p2 = sum(d2.values())
	mini = min(p1, p2)
	p1 = p1 - mini
	p2 = p2 - mini
	ans += mini + p1 + p2
	print(ans)
	t -= 1


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, l, r) = map(int, input().split())
	C = list(map(int, input().split()))
	L = [0] * n
	R = [0] * n
	for i in range(n):
		if i < l:
			L[C[i] - 1] += 1
		else:
			R[C[i] - 1] += 1
	for i in range(n):
		MIN = min(L[i], R[i])
		L[i] -= MIN
		R[i] -= MIN
	PL = 0
	PR = 0
	SUML = 0
	SUMR = 0
	for i in range(n):
		SUML += L[i]
		SUMR += R[i]
		PL += L[i] // 2
		PR += R[i] // 2
	if SUML == SUMR:
		print(SUML)
		continue
	elif SUMR > SUML:
		change = (SUMR - SUML) // 2
		ANS = SUML + change * 2 - min(change, PR)
		print(ANS)
	else:
		change = (SUML - SUMR) // 2
		ANS = SUMR + change * 2 - min(change, PL)
		print(ANS)


t = int(input())
while t:
	(n, l, r) = map(int, input().split())
	a = list(map(int, input().split()))
	p = max(a)
	d1 = {}
	d2 = {}
	for i in range(0, p + 1):
		d1[i] = 0
		d2[i] = 0
	for i in range(0, l):
		d1[a[i]] += 1
	for i in range(0, r):
		d2[a[l + i]] += 1
	if r == l:
		for i in d1.keys():
			if d2[i] > 0 and d1[i] > 0:
				x = min(d1[i], d2[i])
				d1[i] -= x
				d2[i] -= x
		count = 0
		for i in d1.keys():
			count += d1[i]
		print(count)
	elif r > l:
		diff = r - l
		for i in d1.keys():
			if d2[i] > 0 and d1[i] > 0:
				x = min(d1[i], d2[i])
				d1[i] -= x
				d2[i] -= x
		count = 0
		for i in d2.keys():
			if diff == 0:
				break
			temp = d2[i] // 2
			if temp >= diff // 2:
				count = count + diff // 2
				d2[i] = d2[i] - diff
				diff = 0
			else:
				count = count + temp
				d2[i] = d2[i] - temp * 2
				diff = diff - temp * 2
		count = count + diff // 2
		c = 0
		for i in d1.keys():
			c += d1[i]
		for i in d2.keys():
			c += d2[i]
		count = count + c // 2
		print(count)
	elif l > r:
		diff = l - r
		for i in d1.keys():
			if d2[i] > 0 and d1[i] > 0:
				x = min(d1[i], d2[i])
				d1[i] -= x
				d2[i] -= x
		count = 0
		for i in d1.keys():
			if diff == 0:
				break
			temp = d1[i] // 2
			if temp >= diff // 2:
				count = count + diff // 2
				d1[i] = d1[i] - diff
				diff = 0
			else:
				count = count + temp
				d1[i] = d1[i] - temp * 2
				diff = diff - temp * 2
		count = count + diff // 2
		c = 0
		for i in d1.keys():
			c += d1[i]
		for i in d2.keys():
			c += d2[i]
		count = count + c // 2
		print(count)
	t = t - 1


from collections import *
t = int(input())
for _ in range(t):
	(n, l, r) = map(int, input().split())
	L = list(map(int, input().split()))
	d1 = Counter(L[:l])
	d2 = Counter(L[l:])
	ans = 0
	for k in d1:
		if k in d2:
			z = min(d1[k], d2[k])
			d1[k] -= z
			d2[k] -= z
	tot1 = sum([d1[k] for k in d1])
	tot2 = sum([d2[k] for k in d2])
	if tot1 > tot2:
		(tot2, tot1) = (tot1, tot2)
		(d1, d2) = (d2, d1)
	z = sum([d2[k] // 2 for k in d2])
	c = min(z, abs(tot2 - (tot1 + tot2) // 2))
	ans += abs(tot2 - (tot1 + tot2) // 2)
	ans += (tot1 + tot2) // 2 - c
	print(ans)


import os, sys, time, collections, math, pprint as p, itertools as it, operator as op, bisect as bs, functools as fn
(maxx, localsys, mod) = (float('inf'), 0, int(1000000000.0 + 7))
(nCr, ceil) = (lambda n, r: reduce(mul, range(n - r + 1, n + 1), 1) // factorial(r), lambda n, x: (n + x - 1) // x)
(osi, oso) = ('/home/priyanshu/Documents/sublimetextproject/input.txt', '/home/priyanshu/Documents/sublimetextproject/output.txt')
if os.path.exists(osi):
	sys.stdin = open(osi, 'r')
	sys.stdout = open(oso, 'w')
input = sys.stdin.readline

def maps():
	return map(int, input().split())
for _ in range(int(input())):
	(n, L, R) = maps()
	c = list(maps())
	(cl, cr) = ([0] * (n + 1), [0] * (n + 1))
	for i in range(n):
		if i < L:
			cl[c[i]] += 1
		else:
			cr[c[i]] += 1
	for i in range(n + 1):
		mn = min(cl[i], cr[i])
		cl[i] -= mn
		cr[i] -= mn
		L -= mn
		R -= mn
	ans = 0
	if L >= R:
		for i in range(n + 1):
			mn = min(cl[i] // 2 * 2, L - R)
			ans += mn // 2
			L -= mn
	else:
		for i in range(n + 1):
			mn = min(cr[i] // 2 * 2, R - L)
			ans += mn // 2
			R -= mn
	ans += abs(L - R) // 2 + (L + R) // 2
	print(ans)


for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	cl = [0 for _ in range(n)]
	cr = [0 for _ in range(n)]
	socks = list(map(int, input().split()))
	for x in socks[:l]:
		cl[x - 1] += 1
	if r > 0:
		for x in socks[l:]:
			cr[x - 1] += 1
	if l > r:
		(cl, cr) = (cr, cl)
	for i in range(n):
		g = min(cl[i], cr[i])
		cl[i] -= g
		cr[i] -= g
	diff = abs(r - l) // 2
	cost = 0
	i = 0
	while diff > 0 and i < n:
		if cr[i] > 1:
			cr[i] -= 2
			diff -= 1
			cost += 1
		else:
			i += 1
	print(sum(cr) + cost)


import sys
input = sys.stdin.buffer.readline

def map_int():
	return map(int, input().split())

def solve():
	(n, l, r) = map_int()
	c = list(map_int())
	if r > l:
		c = c[l:n] + c[:l]
		(l, r) = (r, l)
	color = [0] * (n + 1)
	for i in range(n):
		color[c[i]] += 1 if i < l else -1
	ans = rem = n // 2 - r
	bad = 0
	for cnt in color:
		if cnt > 1:
			used = min(cnt // 2, rem)
			cnt -= 2 * used
			rem -= used
		if cnt > 0:
			bad += cnt
	print(ans + bad - rem)
for _ in range(int(input())):
	solve()


from collections import Counter
r = lambda : list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	aa = r()
	arr = Counter(aa[:a])
	brr = Counter(aa[a:])
	for i in arr.keys():
		try:
			x = min(arr[i], brr[i])
			a -= x
			b -= x
			arr[i] -= x
			brr[i] -= x
		except:
			pass
	if a < b:
		(a, b) = (b, a)
		(arr, brr) = (brr, arr)
	need = (a - b) // 2
	cost = need
	for i in arr.keys():
		if not need:
			break
		if arr[i] > 1:
			x = min(need, arr[i] // 2)
			need -= x
			arr[i] -= x
			try:
				brr[i] += x
			except:
				brr[i] = x
	for i in arr.keys():
		try:
			x = min(arr[i], brr[i])
			arr[i] -= x
			brr[i] -= x
		except:
			pass
	while need:
		for i in arr.keys():
			if not need:
				break
			if arr[i]:
				need -= 1
				arr[i] -= 1
				try:
					brr[i] += 1
				except:
					brr[i] = 1
	for i in arr.keys():
		try:
			x = min(arr[i], brr[i])
			arr[i] -= x
			brr[i] -= x
		except:
			pass
	print(cost + sum(arr.values()))


from collections import Counter
from sys import stdin, stderr
input = stdin.readline

def dbp(*args, **kwargs):
	pass

def get_int_list():
	return [int(x) for x in input().strip().split()]

def do_thing():
	(n, l, r) = get_int_list()
	assert n % 2 == 0
	assert l + r == n
	clist = get_int_list()
	cset = set(clist)
	lc = Counter(clist[:l])
	rc = Counter(clist[l:])
	if l < r:
		(lc, rc, l, r) = (rc, lc, r, l)
	dbp('start:', l, lc, r, rc)
	for k in cset:
		if k in lc and k in rc:
			v = min(lc[k], rc[k])
			lc[k] -= v
			if lc[k] == 0:
				del lc[k]
			l -= v
			rc[k] -= v
			if rc[k] == 0:
				del rc[k]
			r -= v
	dbp('ezpairs out:', l, lc, r, rc)
	cost = 0
	lcl = list(lc.keys())
	for k in lcl:
		if l > r:
			if lc[k] > 1:
				v = min(l - r, lc[k]) // 2 * 2
				lc[k] -= v
				if lc[k] == 0:
					del lc[k]
				l -= v
				cost += v // 2
		else:
			break
	dbp('cost:', cost, 'lside pairs out:', l, lc, r, rc)
	return cost + l

def multicase():
	maxcc = int(input().strip())
	for cc in range(maxcc):
		print(do_thing())
multicase()


t = int(input())
for case in range(1, t + 1):
	(n, le, ri) = [int(x) for x in input().split(' ')]
	socks = [int(x) for x in input().split(' ')]
	ans = 0
	left = {}
	for sock in socks[:le]:
		if sock in left:
			left[sock] += 1
		else:
			left[sock] = 1
	right = {}
	for sock in socks[le:]:
		if sock in left and left[sock] != 0:
			left[sock] -= 1
			le -= 1
			ri -= 1
		elif sock in right:
			right[sock] += 1
		else:
			right[sock] = 1
	if ri > le:
		(le, ri) = (ri, le)
		(left, right) = (right, left)
	ans += ri
	le -= ri
	for num in left.values():
		pairs = num // 2
		if le - 2 * pairs < 0:
			pairs = le // 2
			le -= 2 * pairs
			ans += pairs
			break
		else:
			le -= 2 * pairs
			ans += pairs
	ans += le
	print(ans)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, l, r) = map(int, input().split())
		ans = 0
		a = list(map(int, input().split()))
		left = [0] * n
		right = [0] * n
		for elem in a[:l]:
			left[elem - 1] += 1
		for elem in a[l:]:
			right[elem - 1] += 1
		for i in range(n):
			minn = min(left[i], right[i])
			left[i] -= minn
			right[i] -= minn
		if l > r:
			diff = (l - r) // 2
			index = 0
			while diff > 0 and index < n:
				cntt = min(left[index] // 2, diff)
				left[index] -= cntt * 2
				diff -= cntt
				ans += cntt
				index += 1
		else:
			diff = (r - l) // 2
			index = 0
			while diff > 0 and index < n:
				cntt = min(right[index] // 2, diff)
				right[index] -= cntt * 2
				diff -= cntt
				ans += cntt
				index += 1
		print(ans + diff + (sum(left) + sum(right)) // 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from __future__ import division, print_function
import os
import sys
from collections import defaultdict
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	t = int(input())
	for _ in range(t):
		(n, l, r) = map(int, input().split())
		l_socks = [0] * n
		r_socks = [0] * n
		for (i, ci) in enumerate(map(int, input().split())):
			if i < l:
				l_socks[ci - 1] += 1
			else:
				r_socks[ci - 1] += 1
		sol = 0
		(l_rem, r_rem) = (0, 0)
		for i in range(n):
			if l > r and l_socks[i] > r_socks[i]:
				t = min((l_socks[i] - r_socks[i]) // 2, (l - r) // 2)
				l_socks[i] -= t
				r_socks[i] += t
				l -= t
				r += t
				sol += t
			elif r > l and r_socks[i] > l_socks[i]:
				t = min((r_socks[i] - l_socks[i]) // 2, (r - l) // 2)
				r_socks[i] -= t
				l_socks[i] += t
				r -= t
				l += t
				sol += t
			m = min(r_socks[i], l_socks[i])
			l_socks[i] -= m
			r_socks[i] -= m
			l_rem += l_socks[i]
			r_rem += r_socks[i]
		print(sol + abs(l_rem - r_rem) // 2 + abs(l_rem + r_rem) // 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
for _ in range(INI()):
	(n, l, r) = INL()
	X = INL()
	D1 = dict()
	for _ in range(l):
		if X[_] in D1:
			D1[X[_]] += 1
		else:
			D1[X[_]] = 1
	D2 = dict()
	for _ in range(l, n):
		if X[_] in D2:
			D2[X[_]] += 1
		else:
			D2[X[_]] = 1
		D1.get(X[_], 0) + 1
	for _ in D1:
		if _ in D2:
			if D1[_] < D2[_]:
				D2[_] -= D1[_]
				D1[_] = 0
			else:
				D1[_] -= D2[_]
				D2[_] = 0
	ans = 0
	(x, y) = (0, 0)
	for _ in D1:
		x += D1[_]
	for _ in D2:
		y += D2[_]
	if x < y:
		ans = x
		for _ in D2:
			if x:
				if D2[_] % 2 == 1:
					D2[_] -= 1
					x -= 1
		for _ in D2:
			if x < D2[_]:
				D2[_] -= x
				x = 0
				break
			else:
				x -= D2[_]
				D2[_] = 0
		for _ in D2:
			ans += (D2[_] + 1) // 2
		OPS(ans)
	else:
		ans = y
		for _ in D1:
			if y:
				if D1[_] % 2 == 1:
					D1[_] -= 1
					y -= 1
		for _ in D1:
			if y < D1[_]:
				D1[_] -= y
				y = 0
				break
			else:
				y -= D1[_]
				D1[_] = 0
		for _ in D1:
			ans += (D1[_] + 1) // 2
		OPS(ans)


from collections import Counter
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	a = list(map(int, input().split()))
	le = Counter(a[:l]) - Counter(a[l:])
	re = Counter(a[l:]) - Counter(a[:l])
	if sum(le.values()) < sum(re.values()):
		(le, re) = (re, le)
	diff = sum(le.values()) - sum(re.values())
	cost = 0
	for i in le.keys():
		if le[i] >= 2:
			if diff >= le[i]:
				cost += le[i] // 2
				diff -= 2 * (le[i] // 2)
				le[i] -= 2 * (le[i] // 2)
			else:
				cost += diff // 2
				le[i] -= diff
				diff = 0
				break
	if diff >= 0:
		cost += 2 * (diff // 2)
	cost += sum(re.values())
	print(cost)


for _ in range(int(input())):
	(n, left, right) = map(int, input().split())
	arr1 = [0] * n
	arr2 = [0] * n
	for (i, x) in enumerate(map(int, input().split())):
		if i < left:
			arr1[x - 1] += 1
		else:
			arr2[x - 1] += 1
	result = abs(left - right) // 2
	diff_pairs = result
	sum_pos = sum_neg = 0
	for i in range(n):
		diff = arr2[i] - arr1[i]
		if diff:
			diff_pairs_local = 0
			if diff_pairs:
				diff_pairs_local = min(abs(diff) // 2, diff_pairs)
			if diff > 0:
				sum_pos += diff
			else:
				sum_neg += -diff
			if (right - left) * diff > 0:
				diff_pairs -= diff_pairs_local
				if diff > 0:
					sum_pos -= diff_pairs_local * 2
				else:
					sum_neg -= diff_pairs_local * 2
	result += max(sum_pos, sum_neg) - diff_pairs
	print(result)


from sys import stdin, stdout
from collections import deque
import bisect
R = lambda : stdin.readline().strip()
RL = lambda f=None: list(map(f, R().split(' '))) if f else list(R().split(' '))
output = lambda x: stdout.write(str(x) + '\n')
output_list = lambda x: output(' '.join(map(str, x)))
import math
from heapq import heappop, heappush, heapify
T = int(input())
for _ in range(T):
	(n, l, r) = RL(int)
	arr = RL(int)
	cc = [[0, 0] for i in range(n)]
	for i in range(n):
		if i < l:
			cc[arr[i] - 1][0] += 1
		else:
			cc[arr[i] - 1][1] += 1
	ans = 0
	tl = 0
	tr = 0
	for i in range(n):
		if cc[i][0] >= cc[i][1]:
			cc[i][0] -= cc[i][1]
			cc[i][1] = 0
			tl += cc[i][0]
		else:
			cc[i][1] -= cc[i][0]
			cc[i][0] = 0
			tr += cc[i][1]
	if tl >= tr:
		ans = tr
		rem = (tl - tr) // 2
		for i in range(n):
			if rem - cc[i][0] // 2 <= 0:
				ans += rem
				rem = 0
				break
			else:
				rem -= cc[i][0] // 2
				ans += cc[i][0] // 2
		ans += rem * 2
		print(ans)
	else:
		ans = tl
		rem = (tr - tl) // 2
		for i in range(n):
			if rem - cc[i][1] // 2 <= 0:
				ans += rem
				rem = 0
				break
			else:
				rem -= cc[i][1] // 2
				ans += cc[i][1] // 2
		ans += rem * 2
		print(ans)


import sys
In = sys.stdin.readline
T = int(In())
for tc in range(1, T + 1):
	(n, l, r) = map(int, In().split())
	color = [0 for _ in range(n + 1)]
	socks = list(map(int, In().split()))
	visited = {}
	(left, right) = ({'total': 0, 'odd': 0}, {'total': 0, 'odd': 0})
	answer = 0
	for i in range(l):
		color[socks[i]] += 1
		visited[socks[i]] = True
	for i in range(l, n):
		color[socks[i]] -= 1
		visited[socks[i]] = True
	for key in visited.keys():
		temp = color[key]
		if temp == 0:
			continue
		if temp > 0:
			left['total'] += temp
			if temp % 2 != 0:
				left['odd'] += 1
		else:
			temp = -temp
			right['total'] += temp
			if temp % 2 != 0:
				right['odd'] += 1
	if left['total'] >= right['total']:
		answer += right['total']
		left['odd'] -= right['total']
		if left['odd'] > 0:
			answer += left['odd']
			answer += (left['total'] - right['total'] - left['odd']) // 2
		else:
			answer += (left['total'] - right['total']) // 2
	else:
		answer += left['total']
		right['odd'] -= left['total']
		if right['odd'] > 0:
			answer += right['odd']
			answer += (right['total'] - left['total'] - right['odd']) // 2
		else:
			answer += (right['total'] - left['total']) // 2
	print(answer)


import sys
from collections import Counter

def read_ints():
	return [int(i) for i in sys.stdin.readline().strip().split()]

def read_int():
	return int(sys.stdin.readline().strip())
t = read_int()
for i in range(t):
	(n, l, r) = read_ints()
	cs = read_ints()
	lefts = Counter(cs[:l])
	rights = Counter(cs[l:])
	if l > r:
		(lefts, rights) = (rights, lefts)
		(r, l) = (l, r)
	cost = 0
	colours = list(lefts.keys())
	for c in colours:
		if c in rights:
			rem = min(lefts[c], rights[c])
			lefts[c] -= rem
			rights[c] -= rem
	to_change_side = (r - l) // 2
	colours = list(rights.keys())
	for c in colours:
		if rights[c] >= 2:
			can_change = min(to_change_side, rights[c] // 2)
			rights[c] -= can_change * 2
			to_change_side -= can_change
			cost += can_change
			if to_change_side == 0:
				break
	assert sum(lefts.values()) <= sum(rights.values())
	cost += (sum(rights.values()) - sum(lefts.values())) // 2
	cost += (sum(lefts.values()) + sum(rights.values())) // 2
	print(cost)


from collections import Counter
from sys import stdin

def read_int():
	return int(stdin.readline())

def read_ints():
	return map(int, stdin.readline().split(' '))
t = read_int()
for case_num in range(t):
	(n, l, r) = read_ints()
	c = list(read_ints())
	lcnt = Counter()
	rcnt = Counter()
	for i in range(n):
		if i < l:
			lcnt[c[i]] += 1
		else:
			rcnt[c[i]] += 1
	for key in lcnt:
		delta = min(lcnt[key], rcnt[key])
		rcnt[key] -= delta
		lcnt[key] -= delta
		l -= delta
		r -= delta
	ans = 0
	for key in lcnt:
		while l > r and lcnt[key] >= 2:
			l -= 2
			lcnt[key] -= 2
			ans += 1
	for key in rcnt:
		while r > l and rcnt[key] >= 2:
			r -= 2
			rcnt[key] -= 2
			ans += 1
	ans += max(l, r)
	print(ans)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left, bisect
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	p = list(map(int, input().split()))
	s = dc(list)
	c = dc(int)
	for i in range(n):
		c[p[i]] += 1
		if c[p[i]] == 1:
			s[p[i]] = [0] * 2
		if i < l:
			s[p[i]][0] += 1
		else:
			s[p[i]][1] += 1
	(l_, r_) = (0, 0)
	t = 0
	l = dc(int)
	r = dc(int)
	for i in s:
		if s[i][0] == s[i][1]:
			continue
		elif s[i][1] > s[i][0]:
			r[i] += s[i][1] - s[i][0]
			r_ += s[i][1] - s[i][0]
		else:
			l[i] += s[i][0] - s[i][1]
			l_ += s[i][0] - s[i][1]
	if l_ == r_:
		t += l_
	elif r_ > l_:
		t += l_
		x = r_ - l_
		s = 0
		for i in r:
			if s >= x:
				break
			if r[i] > 1:
				s += 2 * (r[i] // 2)
		if s >= x:
			t += x // 2
		else:
			t += s // 2
			t += x - s
	else:
		t += r_
		x = l_ - r_
		s = 0
		for i in l:
			if s >= x:
				break
			if l[i] > 1:
				s += 2 * (l[i] // 2)
		if s >= x:
			t += x // 2
		else:
			t += s // 2
			t += x - s
	print(t)


from collections import defaultdict as dd
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	a = list(map(int, input().split()))
	le = dd(int)
	ri = dd(int)
	k = abs(l - r)
	k //= 2
	for i in range(l):
		le[a[i]] += 1
	for i in range(l, n):
		ri[a[i]] += 1
	ans = 0
	for i in ri.keys():
		x = min(ri[i], le[i])
		ri[i] -= x
		le[i] -= x
	if l > r:
		for i in le.keys():
			m = le[i] // 2
			m = min(m, k)
			k -= m
			ans += m
			le[i] -= 2 * m
	else:
		for i in ri.keys():
			m = ri[i] // 2
			m = min(m, k)
			k -= m
			ans += m
			ri[i] -= 2 * m
	k = abs(sum(le.values()) - sum(ri.values()))
	x = min(sum(le.values()), sum(ri.values()))
	ans += x
	ans += k
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
while t:
	t -= 1
	(n, l, r) = [int(x) for x in input().split()]
	temp = [int(x) for x in input().split()]
	if l >= r:
		leftdict = {}
		rightdict = {}
		for color in temp[:l]:
			if color not in leftdict:
				leftdict[color] = 1
			else:
				leftdict[color] += 1
		for color in temp[l:]:
			if color not in rightdict:
				rightdict[color] = 1
			else:
				rightdict[color] += 1
	else:
		leftdict = {}
		rightdict = {}
		for color in temp[l:]:
			if color not in leftdict:
				leftdict[color] = 1
			else:
				leftdict[color] += 1
		for color in temp[:l]:
			if color not in rightdict:
				rightdict[color] = 1
			else:
				rightdict[color] += 1
	for (color, count) in leftdict.items():
		if color in rightdict:
			same = min(count, rightdict[color])
			leftdict[color] -= same
			rightdict[color] -= same
	switch = abs(l - r)
	switch //= 2
	ans = 0
	for (color, count) in leftdict.items():
		if count >= 2 * switch:
			leftdict[color] -= 2 * switch
			ans += switch
			switch = 0
		else:
			leftdict[color] -= count // 2 * 2
			switch -= count // 2
			ans += count // 2
		if switch == 0:
			break
	for color in leftdict:
		ans += leftdict[color]
	print(ans)


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	(n, l, r) = mInt()
	a = lInt()
	s = [0 for i in range(n)]
	left = [0 for i in range(n)]
	right = [0 for i in range(n)]
	for i in range(l):
		s[a[i] - 1] += 1
	for i in range(l, n):
		s[a[i] - 1] -= 1
	for i in range(n):
		if s[i] > 0:
			left[i] = s[i]
		elif s[i] < 0:
			right[i] = -s[i]
	ans = 0
	ls = sum(left)
	rs = sum(right)
	ds = abs(ls - rs)
	if ls > rs:
		(left, right) = (right, left)
		ans += rs
	else:
		ans += ls
	temp = 0
	for i in right:
		temp += i // 2 * 2
	if temp > ds:
		temp = ds
	ans += temp // 2
	ans += ds - temp
	print(ans)


import math

def func(a):
	if a > 0:
		return 0
	elif a < 0:
		return 1
	else:
		return 2
t = int(input())
for _ in range(t):
	(n, l, r) = list(map(int, input().split()))
	socks = list(map(int, input().split()))
	countarr = [0 for i in range(n)]
	for i in range(l):
		countarr[socks[i] - 1] += 1
	for i in range(r):
		countarr[socks[l + i] - 1] -= 1
	countarr.sort(key=func)
	sum = 0
	psum = 0
	for i in range(n):
		if countarr[i] != 0:
			sum += countarr[i]
			psum += abs(countarr[i])
		else:
			break
	dollar = psum // 2 + abs(sum) // 2
	disc = 0
	if sum != 0:
		for i in range(n):
			if countarr[i] != 0:
				if countarr[i] * sum > 0:
					disc += abs(countarr[i]) // 2
			else:
				break
	if disc >= abs(sum) // 2:
		dollar -= abs(sum) // 2
	else:
		dollar -= disc
	print(dollar)


for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	cs = set(c)
	lc = []
	rc = []
	for i in range(n):
		if i < l:
			lc.append(c[i])
		else:
			rc.append(c[i])
	ll = [0] * (n + 1)
	rr = [0] * (n + 1)
	for i in range(len(lc)):
		ll[lc[i]] += 1
	for i in range(len(rc)):
		rr[rc[i]] += 1
	cost = 0
	sl = 0
	sr = 0
	for i in cs:
		t = min(ll[i], rr[i])
		ll[i] -= t
		sl += ll[i]
		rr[i] -= t
		sr += rr[i]
	if sl < sr:
		for i in cs:
			if sl and rr[i] and (rr[i] % 2 != 0):
				rr[i] -= 1
				cost += 1
				sl -= 1
			if sl == 0:
				break
		if sl != 0:
			while sl:
				for i in cs:
					if rr[i] and sl > 1:
						rr[i] -= 2
						sl -= 2
						cost += 2
					elif sl == 1:
						if rr[i]:
							rr[i] -= 1
							sl -= 1
							cost += 1
					if sl == 0:
						break
		srr = 0
		for i in cs:
			if rr[i]:
				cost += rr[i] // 2
				if rr[i] % 2 != 0:
					rr[i] = 1
					srr += 1
		cost += srr
	else:
		for i in cs:
			if sr and ll[i] and (ll[i] % 2 != 0):
				ll[i] -= 1
				sr -= 1
				cost += 1
			if sr == 0:
				break
		if sr != 0:
			while sr:
				for i in cs:
					if ll[i] and sr > 1:
						ll[i] -= 2
						sr -= 2
						cost += 2
					elif sr == 1:
						if ll[i]:
							ll[i] -= 1
							sr -= 1
							cost += 1
					if sr == 0:
						break
		srr = 0
		for i in cs:
			if ll[i]:
				cost += ll[i] // 2
				if ll[i] % 2 != 0:
					ll[i] = 1
					srr += 1
		cost += srr
	print(cost)


for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	sockc = [0] * (n + 1)
	cost = 0
	for i in range(l):
		sockc[c[i]] += 1
	for i in range(l, n):
		sockc[c[i]] -= 1
	pos = 0
	neg = 0
	posodd = 0
	negodd = 0
	for i in range(n + 1):
		if sockc[i] > 0:
			pos += sockc[i]
			posodd += sockc[i] % 2
		elif sockc[i] < 0:
			neg += -sockc[i]
			sockc[i] = -sockc[i]
			negodd += sockc[i] % 2
	if pos == neg:
		print(pos)
	elif pos > neg:
		if posodd > neg:
			posodd -= neg
			print(posodd + (pos + neg - posodd) // 2)
		else:
			print((pos + neg) // 2)
	else:
		t = pos
		pos = neg
		neg = t
		posodd = negodd
		if posodd > neg:
			posodd -= neg
			print(posodd + (pos + neg - posodd) // 2)
		else:
			print((pos + neg) // 2)


from sys import stdin, stdout
from math import sqrt, inf, hypot
from copy import copy
from heapq import heappop, heapify, heappush
from _collections import deque
t = int(stdin.readline())
for _ in range(t):
	(n, l, r) = map(int, stdin.readline().split())
	a = [int(x) for x in stdin.readline().split()]
	d = {}
	for i in range(n):
		d[a[i]] = d.get(a[i], [0, 0])
		if i < l:
			d[a[i]][0] += 1
		else:
			d[a[i]][1] += 1
	ans = 0
	(L, R) = (0, 0)
	cl = 0
	cr = 0
	for c in d.keys():
		x = min(d[c][0], d[c][1])
		d[c][0] -= x
		d[c][1] -= x
		if d[c][0] != 0:
			L += d[c][0]
			if d[c][0] % 2 == 1:
				cl += 1
		else:
			R += d[c][1]
			if d[c][1] % 2 == 1:
				cr += 1
	ans = 0
	if L > R:
		(L, R) = (R, L)
		(cl, cr) = (cr, cl)
	ans += L
	R -= L
	cr = max(0, cr - L)
	R -= cr
	ans += cr
	ans += R // 2
	stdout.write(str(ans) + '\n')


for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	a = [*map(int, input().split())]
	b = {}
	c = {}
	(p, q) = (l, r)
	for i in range(n):
		if i < l:
			b[a[i]] = b.get(a[i], 0) + 1
		else:
			x = b.get(a[i], 0)
			if x == 1:
				p -= 1
				q -= 1
				del b[a[i]]
			elif x > 1:
				p -= 1
				q -= 1
				b[a[i]] -= 1
			else:
				c[a[i]] = c.get(a[i], 0) + 1
	if q > p:
		(p, q) = (q, p)
		(b, c) = (c, b)
	ans = q
	p -= q
	for i in b.values():
		pr = i // 2
		if p - 2 * pr < 0:
			pr = p // 2
			p -= 2 * pr
			ans += pr
			break
		else:
			p -= 2 * pr
			ans += pr
	ans += p
	print(ans)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())

def makeDict(left):
	leftMap = {}
	for item in left:
		if item not in leftMap:
			leftMap[item] = 0
		leftMap[item] += 1
	return leftMap
for _ in range(t):
	(n, l, r) = map(int, input().split())
	left = list(map(int, input().split()))
	right = []
	while len(left) > l:
		right.append(left.pop())
	leftMap = makeDict(left)
	rightMap = makeDict(right)
	lkeys = set(leftMap.keys())
	rkeys = set(rightMap.keys())
	for k in lkeys:
		if k in rkeys:
			mn = min(leftMap[k], rightMap[k])
			leftMap[k] -= mn
			if not leftMap[k]:
				leftMap.pop(k)
			rightMap[k] -= mn
			if not rightMap[k]:
				rightMap.pop(k)
	left = []
	right = []
	(a, b) = (sum(leftMap.values()), sum(rightMap.values()))
	if a < b:
		(leftMap, rightMap) = (rightMap, leftMap)
		(a, b) = (b, a)
	elif a == b:
		pass
	lkeys = leftMap.keys()
	gap = abs(a - b)
	cost = 0
	vals = sorted(leftMap.values(), reverse=True)
	for i in range(len(vals)):
		val = vals[i]
		while gap and val >= 2:
			gap -= 2
			vals[i] -= 2
			val -= 2
			cost += 1
	X = sum(vals)
	while gap:
		cost += 2
		X -= 2
		gap -= 2
	cost += X
	print(cost)


def solve(n, l, r, arr):
	cnt = [0 for i in range(n)]
	if l < r:
		(l, r) = (r, l)
		arr = arr[r:] + arr[:r]
	for (i, c) in enumerate(arr):
		if i < l:
			cnt[c - 1] += 1
		else:
			cnt[c - 1] -= 1
	a = 0
	for c in cnt:
		if c > 0:
			a += c // 2
	return sum((max(c, 0) for c in cnt)) - min(a, (l - r) // 2)
import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for i in range(t):
	(n, l, r) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(solve(n, l, r, arr))


from collections import defaultdict, OrderedDict, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from queue import Queue, PriorityQueue
from heapq import *
from statistics import *
from math import sqrt, log10, log2, log, gcd, ceil, floor
import fractions
import copy
from copy import deepcopy
import sys
import io
sys.setrecursionlimit(10000)
import math
import os
import bisect
import collections
mod = int(pow(10, 9)) + 7
import random
from random import *
from time import time
import itertools
from itertools import combinations

def ncr(n, r, p=mod):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def normalncr(n, r):
	r = min(r, n - r)
	count = 1
	for i in range(n - r, n + 1):
		count *= i
	for i in range(1, r + 1):
		count //= i
	return count
inf = float('inf')
adj = defaultdict(set)
visited = defaultdict(int)

def addedge(a, b):
	adj[a].add(b)
	adj[b].add(a)

def bfs(v):
	q = Queue()
	q.put(v)
	visited[v] = 1
	while q.qsize() > 0:
		s = q.get_nowait()
		print(s)
		for i in adj[s]:
			if visited[i] == 0:
				q.put(i)
				visited[i] = 1

def dfs(v, visited):
	if visited[v] == 1:
		return
	visited[v] = 1
	print(v)
	for i in adj[v]:
		dfs(i, visited)

def reverse_bisect_right(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x > a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

def reverse_bisect_left(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x >= a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

def get_list():
	return list(map(int, input().split()))

def make_list(m):
	m += list(map(int, input().split()))

def get_str_list_in_int():
	return [int(i) for i in list(input())]

def get_str_list():
	return list(input())

def get_map():
	return map(int, input().split())

def input_int():
	return int(input())

def matrix(a, b):
	return [[0 for i in range(b)] for j in range(a)]

def swap(a, b):
	return (b, a)

def find_gcd(l):
	a = l[0]
	for i in range(len(l)):
		a = gcd(a, l[i])
	return a

def is_prime(n):
	sqrta = int(sqrt(n))
	for i in range(2, sqrta + 1):
		if n % i == 0:
			return 0
	return 1

def prime_factors(n):
	while n % 2 == 0:
		return [2] + prime_factors(n // 2)
	sqrta = int(sqrt(n))
	for i in range(3, sqrta + 1, 2):
		if n % i == 0:
			return [i] + prime_factors(n // i)
	return [n]

def p(a):
	if type(a) == str:
		print(a + '\n')
	else:
		print(str(a) + '\n')

def ps(a):
	if type(a) == str:
		print(a)
	else:
		print(str(a))

def kth_no_not_div_by_n(n, k):
	return k + (k - 1) // (n - 1)

def forward_array(l):
	n = len(l)
	stack = []
	forward = [0] * n
	for i in range(len(l) - 1, -1, -1):
		while len(stack) and l[stack[-1]] < l[i]:
			stack.pop()
		if len(stack) == 0:
			forward[i] = len(l)
		else:
			forward[i] = stack[-1]
		stack.append(i)
	return forward

def backward_array(l):
	n = len(l)
	stack = []
	backward = [0] * n
	for i in range(len(l)):
		while len(stack) and l[stack[-1]] < l[i]:
			stack.pop()
		if len(stack) == 0:
			backward[i] = -1
		else:
			backward[i] = stack[-1]
		stack.append(i)
	return backward

def char(a):
	return chr(a + 97)

def get_length(a):
	return 1 + int(log10(a))

def issq(n):
	sqrta = int(n ** 0.5)
	return sqrta ** 2 == n

def ceil(a, b):
	return int((a + b - 1) / b)

def equal_sum_partition(arr, n):
	sum = 0
	for i in range(n):
		sum += arr[i]
	if sum % 2 != 0:
		return False
	part = [[True for i in range(n + 1)] for j in range(sum // 2 + 1)]
	for i in range(0, n + 1):
		part[0][i] = True
	for i in range(1, sum // 2 + 1):
		part[i][0] = False
	for i in range(1, sum // 2 + 1):
		for j in range(1, n + 1):
			part[i][j] = part[i][j - 1]
			if i >= arr[j - 1]:
				part[i][j] = part[i][j] or part[i - arr[j - 1]][j - 1]
	return part[sum // 2][n]

def bin_sum_array(arr, n):
	for i in range(n):
		if arr[i] % 2 == 1:
			return i + 1
	binarray = [list(reversed(bin(i)[2:])) for i in arr]
	new_array = [0 for i in range(32)]
	for i in binarray:
		for j in range(len(i)):
			if i[j] == '1':
				new_array[j] += 1
	return new_array
nc = 'NO'
yc = 'YES'
ns = 'No'
ys = 'Yes'

def yesno(a):
	print(yc if a else nc)
t = 1

def reduce(dict, a):
	dict[a] -= 1
	if dict[a] == 0:
		dict.pop(a)

def double_finder(dict):
	count = 0
	for i in dict:
		count += dict[i] // 2
	return count
t = int(input())
for i in range(t):
	(n, l, r) = get_list()
	socks = get_list()
	left = defaultdict(int)
	right = defaultdict(int)
	pairs = 0
	cost = 0
	leftcount = l
	rightcount = r
	for i in range(l):
		left[socks[i]] += 1
	for i in range(l, l + r):
		if socks[i] in left:
			reduce(left, socks[i])
			pairs += 1
			leftcount -= 1
			rightcount -= 1
			if pairs == n / 2:
				break
			continue
		right[socks[i]] += 1
	if pairs == n / 2:
		print(cost)
	elif leftcount == rightcount:
		print(leftcount)
	elif leftcount < rightcount:
		counta = double_finder(right)
		rightcount -= leftcount
		counta = min(counta, rightcount // 2)
		cost += leftcount
		print(cost + rightcount - counta)
	elif leftcount > rightcount:
		counta = double_finder(left)
		leftcount -= rightcount
		cost += rightcount
		counta = min(counta, leftcount // 2)
		print(cost + leftcount - counta)


t = int(input())
for f in range(t):
	(n, l, r) = map(int, input().split())
	p = [int(x) for x in input().split()]
	le = p[0:l]
	ri = p[l:]
	le.sort()
	ri.sort()
	i = 0
	j = 0
	le1 = []
	ri1 = []
	while i < l and j < r:
		if le[i] == ri[j]:
			i += 1
			j += 1
		elif le[i] > ri[j]:
			ri1.append(ri[j])
			j += 1
		else:
			le1.append(le[i])
			i += 1
	while i < l:
		le1.append(le[i])
		i += 1
	while j < r:
		ri1.append(ri[j])
		j += 1
	cost = 0
	if l > r:
		i = 1
		while i < len(le1) and cost != (l - r) / 2:
			if le1[i] == le1[i - 1]:
				cost += 1
				i += 2
			else:
				i += 1
		print(len(le1) - cost)
	else:
		j = 1
		while j < len(ri1) and cost != (r - l) / 2:
			if ri1[j] == ri1[j - 1]:
				cost += 1
				j += 2
			else:
				j += 1
		print(len(ri1) - cost)


for i in range(int(input())):
	(n, l, r) = map(int, input().split())
	allsocks = list(map(int, input().split()))
	leftsocks = sorted(allsocks[:l])
	rightsocks = sorted(allsocks[l:])
	a = b = 0
	while a < l and b < r:
		if leftsocks[a] < rightsocks[b]:
			a += 1
		elif leftsocks[a] > rightsocks[b]:
			b += 1
		else:
			leftsocks[a] = rightsocks[b] = 0
			a += 1
			b += 1
	ll = l - leftsocks.count(0)
	lr = r - rightsocks.count(0)
	same = 0
	p = 0
	if l > r and ll > 1:
		while p < l - 1:
			if leftsocks[p] == leftsocks[p + 1] and leftsocks[p] != 0:
				same += 1
				p += 2
			else:
				p += 1
	if r > l and lr > 1:
		while p < r - 1:
			if rightsocks[p] == rightsocks[p + 1] and rightsocks[p] != 0:
				same += 1
				p += 2
			else:
				p += 1
	print(abs(l - r) // 2 + (ll + lr) // 2 - min(abs(l - r) // 2, same))


def solve():
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	lc = [0] * (n + 1)
	rc = [0] * (n + 1)
	res = 0
	for i in range(l):
		lc[c[i]] += 1
	for i in range(l, n):
		rc[c[i]] += 1
	for i in range(n):
		d = min(lc[i], rc[i])
		lc[i] -= d
		rc[i] -= d
	for i in range(n + 1):
		if lc[i] > rc[i]:
			if l > r:
				d = (l - r) // 2
				give = min((lc[i] - rc[i]) // 2, d)
				rc[i] += give
				lc[i] -= give
				l -= give
				r += give
				res += give
		elif r > l:
			d = (r - l) // 2
			give = min((rc[i] - lc[i]) // 2, d)
			r -= give
			l += give
			rc[i] -= give
			lc[i] += give
			res += give
	res += abs(r - l) // 2
	d = 0
	for i in range(n + 1):
		d += abs(lc[i] - rc[i])
	res += d // 2 + int(d % 2 == 1)
	print(res)

def main():
	for _ in range(int(input())):
		solve()
main()


for tc in range(int(input())):
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	if l == r:
		dic = {}
		for i in range(l):
			if c[i] not in dic:
				dic[c[i]] = 0
			dic[c[i]] += 1
		left = r
		for i in range(l, n):
			if c[i] in dic and dic[c[i]] > 0:
				dic[c[i]] -= 1
				left -= 1
		print(left)
	elif l > r:
		dic = {}
		for i in range(l):
			if c[i] not in dic:
				dic[c[i]] = 0
			dic[c[i]] += 1
		left = r
		for i in range(l, n):
			if c[i] in dic and dic[c[i]] > 0:
				dic[c[i]] -= 1
				left -= 1
		rem = (l - r) // 2
		ans = 0
		for i in dic:
			if rem == 0:
				break
			if dic[i] >= 2:
				s = dic[i] // 2 if dic[i] // 2 <= rem else rem
				rem -= s
				dic[i] -= s * 2
				ans += s
		print(ans + left + 2 * rem)
	elif r > l:
		dic = {}
		for i in range(l, n):
			if c[i] not in dic:
				dic[c[i]] = 0
			dic[c[i]] += 1
		left = l
		for i in range(l):
			if c[i] in dic and dic[c[i]] > 0:
				dic[c[i]] -= 1
				left -= 1
		rem = (r - l) // 2
		ans = 0
		for i in dic:
			if rem == 0:
				break
			if dic[i] >= 2:
				s = dic[i] // 2 if dic[i] // 2 <= rem else rem
				rem -= s
				dic[i] -= s * 2
				ans += s
		print(ans + left + 2 * rem)


from collections import defaultdict
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	v = list(map(int, input().split()))
	d = defaultdict(list)
	for i in range(len(v)):
		if i < l:
			d[v[i]].append('l')
		else:
			d[v[i]].append('r')
	cntl = 0
	cntr = 0
	ans = 0
	for i in d:
		x = d[i].count('l')
		y = d[i].count('r')
		if x > y:
			d[i] = ['l'] * (x - y)
			cntl += x - y
		elif y > x:
			d[i] = ['r'] * (y - x)
			cntr += y - x
		else:
			d[i] = [0]
	freq = []
	ans += min(cntl, cntr)
	if cntl == cntr:
		print(cntl)
		continue
	for i in d:
		if cntl < cntr:
			z = d[i].count('r')
			freq.append(z)
		elif cntr < cntl:
			z = d[i].count('l')
			freq.append(z)
	freq.sort()
	cur = 0
	i = 0
	ind = 0
	while cur < min(cntl, cntr) and i < len(freq):
		if cur + 1 < min(cntl, cntr) and freq[i] % 2:
			cur += 1
			freq[i] -= 1
		elif cur + 1 == min(cntl, cntr) and freq[i] % 2:
			freq[i] -= 1
			cur += 1
			break
		i += 1
	freq.sort(reverse=True)
	i = 0
	while cur < min(cntl, cntr) and i < len(freq):
		if cur + freq[i] < min(cntl, cntr):
			cur += freq[i]
			freq[i] = 0
			i += 1
		elif cur + freq[i] >= min(cntl, cntr):
			freq[i] -= min(cntl, cntr) - cur
			break
	cnt_final = 0
	for i in range(0, len(freq)):
		ans += freq[i] // 2
		if freq[i] % 2:
			cnt_final += 1
	ans += cnt_final
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd
for t in range(int(input())):
	(n, l, r) = map(int, input().split())
	a = list(map(int, input().split()))
	d1 = dd(int)
	d2 = dd(int)
	for i in range(l):
		d1[a[i]] += 1
	for i in range(l, n):
		d2[a[i]] += 1
	if l > r:
		(l, r) = (r, l)
		(d1, d2) = (d2, d1)
	c = 0
	for i in d1:
		x = min(d1[i], d2[i])
		d1[i] -= x
		d2[i] -= x
		c += x
	ans = l - c
	for i in d2:
		if l == n // 2:
			break
		if d2[i] > 1:
			x = min(d2[i] // 2, n // 2 - l)
			l += x
			ans += x
			d2[i] -= x
	if l < n // 2:
		ans += 2 * (n // 2 - l)
	print(ans)


from collections import deque, Counter
from collections import defaultdict as dfd
from bisect import bisect, bisect_left
from math import sqrt, gcd, ceil, factorial
from heapq import heapify, heappush, heappop
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
inf = float('inf')
ans_ = []

def nin():
	return int(input())

def ninf():
	return int(file.readline())

def st():
	return input().strip()

def stf():
	return file.readline().strip()

def read():
	return list(map(int, input().strip().split()))

def readf():
	return list(map(int, file.readline().strip().split()))

def readfl():
	return list(map(float, input().strip().split()))

def readffl():
	return list(map(float, file.readline().strip().split()))

def solve():
	for _ in range(nin()):
		(n, l, r) = read()
		arr = read()
		larr = Counter(arr[:l])
		rarr = Counter(arr[l:])
		for i in larr:
			x = min(larr[i], rarr[i])
			larr[i] -= x
			rarr[i] -= x
		l = sum([larr[i] for i in larr])
		r = sum([rarr[i] for i in rarr])
		if l < r:
			(r, l) = (l, r)
			(larr, rarr) = (rarr, larr)
		trans = (l - r) // 2
		ans = 2 * trans + r
		for i in larr:
			while trans > 0 and larr[i] > 1:
				trans -= 1
				ans -= 1
				larr[i] -= 2
		ans_.append(ans)
solve()
for i in ans_:
	print(i)


import sys, getpass
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
M9 = 10 ** 9 + 7
MAXINT = sys.maxsize
OFFLINE_TEST = getpass.getuser() == 'hkmac'

def log(*args):
	if OFFLINE_TEST:
		print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)

def solve(*args):
	if OFFLINE_TEST:
		log('----- solving ------')
		log(*args)
		log('----- ------- ------')
	return solve_(*args)

def read_matrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def read_strings(rows):
	return [input().strip() for _ in range(rows)]

def solve_(arr, brr):
	if len(arr) < len(brr):
		(arr, brr) = (brr, arr)
	diff = len(arr) - len(brr)
	c1 = Counter(arr)
	c2 = Counter(brr)
	for k in list(c1.keys()):
		comb = min(c1[k], c2[k])
		c1[k] -= comb
		c2[k] -= comb
		if c1[k] == 0:
			del c1[k]
		if c2[k] == 0:
			del c2[k]
	log(c1)
	log(c2)
	asum = sum(c1.values())
	bsum = sum(c2.values())
	matched = 0
	for k in list(c1.keys()):
		flip = c1[k] // 2
		matched += flip
		c1[k] -= flip * 2
	return bsum + max((asum - bsum) // 2, asum - bsum - matched)
	return res
for case_num in range(int(input())):
	(_, left, right) = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	arr = lst[:left]
	brr = lst[left:]
	res = solve(arr, brr)
	print(res)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, l, r) = map(int, stdin.readline().split())
	arr = list(map(int, stdin.readline().split()))
	color = {}
	for a in range(l, n):
		if color.get(arr[a]) != None:
			color[arr[a]] += 1
		else:
			color[arr[a]] = 1
	left = {}
	for a in range(l):
		if left.get(arr[a]) != None:
			left[arr[a]] += 1
		else:
			left[arr[a]] = 1
	right = color.keys()
	l = 0
	ans = 0
	rr = 0
	for r in right:
		if left.get(r) != None:
			if left[r] < color[r]:
				color[r] = color[r] - left[r]
				left[r] = 0
			else:
				left[r] = left[r] - color[r]
				color[r] = 0
	l = sum(left.values())
	rr = sum(color.values())
	lkeys = left.keys()
	if l == rr:
		ans = l
	else:
		if l > rr:
			for i in lkeys:
				if left[i] > 1:
					while rr != l and left[i] > 1:
						left[i] = left[i] - 2
						l -= 2
						ans += 1
				if l == rr:
					break
		else:
			for i in right:
				if color[i] > 1:
					while rr != l and color[i] > 1:
						color[i] -= 2
						rr -= 2
						ans += 1
				if l == rr:
					break
		ans += abs(l - rr) // 2 + (l + rr) // 2
	print(ans)


import sys
input = sys.stdin.buffer.readline
for t in range(int(input())):
	(N, L, R) = map(int, input().split())
	A = list(map(int, input().split()))
	for i in range(N):
		A[i] -= 1
	if L > R:
		A = A[L:] + A[:L]
		(L, R) = (R, L)
	C = [0] * N
	for i in range(L):
		C[A[i]] += 1
	for i in range(L, N):
		C[A[i]] -= 1
	X = R - L >> 1
	Y = X
	F = [0] * N
	for i in range(L):
		F[i] = 1
	for i in range(L, N):
		if C[A[i]] <= -2 and X > 0:
			C[A[i]] += 2
			X -= 1
			F[i] = 1
	print(Y + (sum([abs(C[i]) for i in range(N)]) >> 1))


from collections import Counter
rr = input
rri = lambda : int(rr())
rrm = lambda : list(map(int, rr().split()))
T = rri()

def diff_dict(lcounter, rcounter):
	count = 0
	if len(lcounter) < len(rcounter):
		for (k, v) in list(lcounter.items()):
			if k in rcounter:
				temp = min(v, rcounter[k])
				count += temp
				lcounter[k] -= temp
				rcounter[k] -= temp
				if lcounter[k] == 0:
					del lcounter[k]
				if rcounter[k] == 0:
					del rcounter[k]
	else:
		for (k, v) in list(rcounter.items()):
			if k in lcounter:
				temp = min(v, lcounter[k])
				count += temp
				lcounter[k] -= temp
				rcounter[k] -= temp
				if lcounter[k] == 0:
					del lcounter[k]
				if rcounter[k] == 0:
					del rcounter[k]
	return count

def total_pairs(counter):
	total = 0
	for v in counter.values():
		total += v // 2
	return total

def solve():
	(n, l, r) = rrm()
	lst = rrm()
	llst = lst[:l]
	rlst = lst[l:]
	lcounter = dict(Counter(llst))
	rcounter = dict(Counter(rlst))
	removed = diff_dict(lcounter, rcounter)
	l -= removed
	r -= removed
	n -= removed * 2
	if l == r:
		return n // 2
	elif l > r:
		diff = l - r
		pairs = total_pairs(lcounter)
		extra = max(0, diff - pairs * 2)
		return (n + extra) // 2
	else:
		diff = r - l
		pairs = total_pairs(rcounter)
		extra = max(0, diff - pairs * 2)
		return (n + extra) // 2
for t in range(T):
	print(solve())


for u in range(int(input())):
	(n, l, r) = map(int, input().split())
	x = []
	x.append([0 for i in range(n)])
	x.append([0 for i in range(n)])
	y = [int(w) for w in input().split()]
	for i in range(n):
		t = y[i]
		if i < l:
			x[0][t - 1] += 1
		else:
			x[1][t - 1] += 1
	for i in range(n):
		t = min(x[0][i], x[1][i])
		x[0][i] -= t
		x[1][i] -= t
	a1 = 0
	a2 = 0
	for i in range(n):
		a1 += x[0][i]
		a2 += x[1][i]
	ans = 0
	if a1 < a2:
		i = 0
		while i < n and a1 != a2:
			if x[1][i] > 1:
				a2 -= 2
				x[1][i] -= 2
				ans += 1
				i -= 1
			i += 1
	else:
		i = 0
		while i < n and a1 != a2:
			if x[0][i] > 1:
				a1 -= 2
				x[0][i] -= 2
				ans += 1
				i -= 1
			i += 1
	ans = ans + max(a1, a2)
	print(ans)


from collections import Counter
import sys
input = sys.stdin.readline

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	(n, l, r) = rl()
	ss = rl()
	ll = ss[:l]
	rr = ss[l:]
	L = Counter(ll)
	R = Counter(rr)
	All = Counter(ss)
	solution = 0
	left_alone = 0
	right_alone = 0
	left_pairs = 0
	right_pairs = 0
	for k in All.keys():
		if L[k] > R[k]:
			excess = L[k] - R[k]
			parity = excess % 2
			left_alone += parity
			left_pairs += excess - parity
		elif L[k] < R[k]:
			excess = R[k] - L[k]
			parity = excess % 2
			right_alone += parity
			right_pairs += excess - parity
	if left_alone > right_alone:
		(left_alone, left_pairs, right_alone, right_pairs) = (right_alone, right_pairs, left_alone, left_pairs)
	solution += left_alone
	right_alone -= left_alone
	left_alone = 0
	if right_alone > left_pairs:
		solution += left_pairs
		right_alone -= left_pairs
		left_pairs = 0
		solution += right_pairs // 2 + right_alone
	else:
		solution += right_alone
		left_pairs -= right_alone
		solution += right_pairs // 2 + left_pairs // 2
	print(solution)


import sys
import math
import random
input = sys.stdin.readline

def pow(a, n, m):
	if n == 0:
		return 1
	x = pow(a, n // 2, m)
	if n % 2 == 0:
		return x * x % m
	else:
		return x * x * a % m
t = int(input())
while t > 0:
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	a = [0 for i in range(n)]
	for i in range(n):
		if i < l:
			a[c[i] - 1] += 1
		else:
			a[c[i] - 1] -= 1
	ans = 0
	le = 0
	lee = 0
	rii = 0
	ri = 0
	c = 0
	for i in a:
		if i > 0:
			le += i
		elif i < 0:
			i = abs(i)
			ri += i
	if le == ri:
		print(le)
	elif le > ri:
		x = (le - ri) // 2
		i = 0
		while x > 0 and i < n:
			if a[i] > 1:
				y = a[i] // 2
				z = min(x, y)
				ans += z
				a[i] = a[i] - 2 * z
				x -= z
			i += 1
		for i in a:
			if i > 0:
				ans += i
		print(ans)
	else:
		x = (ri - le) // 2
		i = 0
		while x > 0 and i < n:
			if a[i] < -1:
				y = abs(a[i]) // 2
				z = min(x, y)
				ans += z
				a[i] = a[i] + 2 * z
				x -= z
			i += 1
		for i in a:
			if i < 0:
				ans += abs(i)
		print(ans)
	t -= 1


import sys
read = sys.stdin.read
from collections import Counter, deque
from copy import deepcopy

def main():
	(t, *data) = map(int, read().split())
	cnt = 0
	for _ in range(t):
		(n, l, r) = (data[cnt], data[cnt + 1], data[cnt + 2])
		socks_l = deque(sorted(data[cnt + 3:cnt + 3 + l]))
		socks_r = deque(sorted(data[cnt + 3 + l:cnt + 3 + n]))
		cnt += n + 3
		socks_l2 = list()
		socks_r2 = list()
		while socks_l or socks_r:
			if not socks_l:
				socks_r2.extend(socks_r)
				break
			elif not socks_r:
				socks_l2.extend(socks_l)
				break
			elif socks_l[0] == socks_r[0]:
				_2 = socks_l.popleft()
				_2 = socks_r.popleft()
			elif socks_l[0] < socks_r[0]:
				socks_l2.append(socks_l.popleft())
			else:
				socks_r2.append(socks_r.popleft())
		len_l2 = len(socks_l2)
		len_r2 = len(socks_r2)
		if len_l2 > len_r2:
			many = len_l2
			few = len_r2
			sets = sum([v // 2 for v in Counter(socks_l2).values()])
		else:
			many = len_r2
			few = len_l2
			sets = sum([v // 2 for v in Counter(socks_r2).values()])
		diff = many - few
		ans = diff + few
		if diff <= sets * 2:
			ans = min(ans, diff // 2 + few)
		else:
			ans = min(ans, many - sets)
		print(ans)
main()


from collections import Counter
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	s = list(map(int, input().split()))
	s1 = s[:l]
	s2 = s[l:]
	ans = 0
	if len(s1) > len(s2):
		(s1, s2) = (s2, s1)
	d = Counter(s2)
	q = Counter(s1)
	for i in q.keys():
		if i in d.keys():
			if d[i] >= q[i]:
				d[i] -= q[i]
			else:
				ans += q[i] - d[i]
				d[i] = 0
		else:
			ans += q[i]
	t = abs(n // 2 - l)
	ans += t
	x = 0
	for i in d.keys():
		x += d[i] // 2
	if x < t:
		ans += t - x
	print(ans)


import sys
import collections
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(N, L, R) = [int(x) for x in input().split()]
		C = [int(x) for x in input().split()]
		left = []
		right = []
		left_c = collections.Counter()
		right_c = collections.Counter()
		for (i, c) in enumerate(C):
			if i < L:
				left.append(c)
				left_c[c] += 1
			else:
				right.append(c)
				right_c[c] += 1
		for i in range(1, N + 1):
			mi = min(left_c[i], right_c[i])
			left_c[i] -= mi
			right_c[i] -= mi
		ans = 0
		if L > R:
			diff = abs(L - R) // 2
			for i in range(1, N + 1):
				if left_c[i] >= 2:
					pair = left_c[i] // 2
					mi = min(pair, diff)
					left_c[i] -= mi * 2
					ans += mi
					diff -= mi
				if diff == 0:
					break
			for i in range(1, N + 1):
				ans += left_c[i]
		else:
			diff = abs(L - R) // 2
			for i in range(1, N + 1):
				if right_c[i] >= 2:
					pair = right_c[i] // 2
					mi = min(pair, diff)
					right_c[i] -= mi * 2
					ans += mi
					diff -= mi
				if diff == 0:
					break
			for i in range(1, N + 1):
				ans += right_c[i]
		print(ans)
main()


def answer():
	rc = [0] * (n + 1)
	lc = [0] * (n + 1)
	for i in range(n):
		if i < l:
			lc[a[i]] += 1
		else:
			rc[a[i]] += 1
	v = n // 2
	left = max(0, v - l) + max(0, v - r)
	for i in range(n + 1):
		m = min(rc[i], lc[i])
		rc[i] -= m
		lc[i] -= m
	(ans, extra) = (0, 0)
	for i in range(n + 1):
		if l > r:
			v = min(lc[i] // 2, left)
			ans += v
			left -= v
			lc[i] -= 2 * v
			extra += lc[i] + rc[i]
		else:
			v = min(rc[i] // 2, left)
			ans += v
			left -= v
			rc[i] -= 2 * v
			extra += lc[i] + rc[i]
	return ans + extra // 2 + left
for T in range(int(input())):
	(n, l, r) = map(int, input().split())
	a = list(map(int, input().split()))
	print(answer())


import sys
from collections import deque
from queue import PriorityQueue
from math import gcd
from math import log
from math import ceil
from math import pi
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
for _ in range(ii()):
	(n, l, r) = il()
	a = il()
	ans = abs(l - r)
	t = ans // 2
	d = {}
	for i in range(l):
		d[a[i]] = d.get(a[i], 0) + 1
	for i in range(l, n):
		d[a[i]] = d.get(a[i], 0) - 1
	t1 = 0
	if l > r:
		for i in d:
			if d[i] > 0:
				mn = min(t, d[i] // 2)
				t -= mn
				d[i] -= 2 * mn
	elif r > l:
		for i in d:
			if d[i] < 0:
				mn = min(t, -d[i] // 2)
				t -= mn
				d[i] += 2 * mn
	for i in d:
		t1 += abs(d[i])
	print((ans + t1) // 2)


from collections import Counter
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	arr = list(map(int, input().split()))
	if l > r:
		(l, r) = (r, l)
		arr = arr[::-1]
	left = [0] * n
	right = [0] * n
	for i in range(n):
		if i < l:
			left[arr[i] - 1] += 1
		else:
			right[arr[i] - 1] += 1
	pairs = 0
	ep = 0
	for i in range(n):
		m = min(left[i], right[i])
		pairs += m
		left[i] -= m
		right[i] -= m
		ep += right[i] // 2
	want = n // 2
	rem = want - pairs
	cost = rem + max(0, r - want - ep)
	print(cost)


from collections import Counter

def f(l, r, a):
	cnt = (l + r) // 2
	left = Counter(a[:l])
	right = Counter(a[l:])
	x = abs(l - r) // 2
	if l > r:
		(right, left) = (left, right)
	for i in left:
		m = min(left[i], right[i])
		left[i] -= m
		right[i] -= m
		cnt -= m
	rem = 0
	for i in right:
		rem += right[i] // 2
	return cnt + (x - min(x, rem))
for i in range(int(input())):
	(n, l, r) = map(int, input().strip().split())
	b = list(map(int, input().strip().split()))
	print(f(l, r, b))


from collections import Counter
t = int(input())
for _ in range(t):
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	left = c[0:l]
	right = c[l:]
	dl = Counter(left)
	dr = Counter(right)
	(pairs, ans) = (0, 0)
	for key in dl:
		ma = min(dl[key], dr[key])
		pairs += ma
		dl[key] -= ma
		dr[key] -= ma
	req = abs(l - r) // 2
	if r > l:
		kr = sorted(dr, key=dr.get, reverse=True)
		i = 0
		while i < len(kr) and req > 0:
			if dr[kr[i]] > 1:
				av = dr[kr[i]] // 2
				if req > av:
					pairs += av
					ans += av
					req -= av
				else:
					pairs += req
					ans += req
					req = 0
			elif dr[kr[i]] == 1:
				ans += 1
				req -= 1
			i += 1
	else:
		kl = sorted(dl, key=dl.get, reverse=True)
		i = 0
		while i < len(kl) and req > 0:
			if dl[kl[i]] > 1:
				av = dl[kl[i]] // 2
				if req > av:
					pairs += av
					ans += av
					req -= av
				else:
					pairs += req
					ans += req
					req = 0
			elif dl[kl[i]] == 1:
				ans += 1
				req -= 1
			i += 1
	print(ans + n // 2 - pairs + req)


def main():
	t = int(input())
	for i in range(t):
		solve()

def solve():
	(n, l, r) = map(int, input().split())
	a = list(map(int, input().split()))
	r = a[l:]
	l = a[:l]
	r.sort()
	l.sort()
	matched = 0
	pass
	pl = len(l) - 1
	pr = len(r) - 1
	while pr != -1 and pl != -1:
		if r[pr] == l[pl]:
			matched += 1
			r.pop(pr)
			l.pop(pl)
			pl -= 1
			pr -= 1
		elif r[pr] > l[pl]:
			pr -= 1
		else:
			pl -= 1
	half = 0
	if len(r) - len(l) >= 2:
		for i in range(len(r) - 2, -1, -1):
			if i < len(r) - 1 and r[i] == r[i + 1]:
				r.pop(i + 1)
				r.pop(i)
				half += 1
			if len(r) == len(l):
				break
	if len(l) - len(r) >= 2:
		for i in range(len(l) - 2, -1, -1):
			if i < len(l) - 1 and l[i] == l[i + 1]:
				l.pop(i + 1)
				l.pop(i)
				half += 1
			if len(l) == len(r):
				break
	print(n - matched * 2 - half - min(len(r), len(l)))
main()


import sys
(*data,) = sys.stdin.read().split('\n')[::-1]

def input():
	return data.pop()
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	(*socks,) = map(int, input().split())
	left_colors = [0] * n
	right_colors = [0] * n
	for v in socks[:l]:
		left_colors[v - 1] += 1
	for v in socks[l:]:
		if left_colors[v - 1]:
			left_colors[v - 1] -= 1
			l -= 1
			r -= 1
		else:
			right_colors[v - 1] += 1
	n = l + r
	cost = 0
	if l < r:
		(l, r) = (r, l)
		(left_colors, right_colors) = (right_colors, left_colors)
	disb = n // 2 - r
	for (i, v) in enumerate(left_colors):
		diff = min(disb, v // 2)
		cost += diff
		disb -= diff
		left_colors[i] -= diff * 2
		l -= diff * 2
	n = l + r
	print(cost + n // 2 - min(l, r) + n // 2)


from collections import defaultdict
import math
import heapq
t = int(input())
for _ in range(t):
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	le = c[:l]
	ri = c[l:]
	if l == r:
		d1 = defaultdict(lambda : 0)
		cnt = 0
		for j in le:
			d1[j] += 1
		for j in ri:
			if d1[j]:
				d1[j] += -1
			else:
				cnt += 1
		print(cnt)
	elif l > r:
		d1 = defaultdict(lambda : 0)
		cnt = 0
		for j in le:
			d1[j] += 1
		for j in ri:
			if d1[j]:
				d1[j] += -1
			else:
				cnt += 1
		tot = n // 2 - r
		for j in d1:
			while tot > 0 and d1[j] > 1:
				cnt += 1
				d1[j] += -2
				tot += -1
			if tot == 0:
				break
		print(cnt + tot * 2)
	elif r > l:
		(l, r) = (r, l)
		(le, ri) = (ri, le)
		d1 = defaultdict(lambda : 0)
		cnt = 0
		for j in le:
			d1[j] += 1
		for j in ri:
			if d1[j]:
				d1[j] += -1
			else:
				cnt += 1
		tot = n // 2 - r
		for j in d1:
			while tot > 0 and d1[j] > 1:
				cnt += 1
				d1[j] += -2
				tot += -1
			if tot == 0:
				break
		print(cnt + tot * 2)


g = int(input())
while g > 0:
	g -= 1
	(n, L, R) = map(int, input().split())
	a = list(map(int, input().split()))
	l = {}
	r = {}
	for i in range(n):
		if i < L:
			if a[i] not in l:
				l[a[i]] = 0
			l[a[i]] += 1
		else:
			if a[i] not in r:
				r[a[i]] = 0
			r[a[i]] += 1
	if R > L:
		(l, r) = (r, l)
		(L, R) = (R, L)
	ans = 0
	for i in l:
		if i in r:
			t = min(l[i], r[i])
			l[i] -= t
			r[i] -= t
			L -= t
			R -= t
	diff = L - R
	for i in l:
		if diff > 0:
			t = min(diff, l[i]) // 2
			diff -= t * 2
			L -= t * 2
			l[i] -= t * 2
			ans += t
	print(ans + L)


t = int(input())
for i in range(t):
	(n, l, r) = map(int, input().split())
	z = list(map(int, input().split()))
	left_col = z[:l]
	right_col = z[l:]
	d1 = {}
	d2 = {}
	for j in range(1, n + 1):
		d1[j] = 0
		d2[j] = 0
	for j in range(len(left_col)):
		d1[left_col[j]] += 1
	for j in range(len(right_col)):
		d2[right_col[j]] += 1
	cnt = 0
	if l == r:
		for j in range(1, n + 1):
			qa = min(d1[j], d2[j])
			d1[j] -= qa
			d2[j] -= qa
			cnt += d1[j] + d2[j]
		money = cnt // 2
	elif l > r:
		spl = 0
		for j in range(1, n + 1):
			qa = min(d1[j], d2[j])
			d1[j] -= qa
			d2[j] -= qa
			cnt += d1[j] + d2[j]
			if d1[j] > 1:
				spl += d1[j] // 2
		if spl <= (l - r) // 2:
			money = (l - r) // 2 + cnt // 2 - spl
		else:
			money = cnt // 2
	else:
		spl = 0
		for j in range(1, n + 1):
			qa = min(d1[j], d2[j])
			d1[j] -= qa
			d2[j] -= qa
			cnt += d1[j] + d2[j]
			if d2[j] > 1:
				spl += d2[j] // 2
		if spl <= (r - l) // 2:
			money = (r - l) // 2 + cnt // 2 - spl
		else:
			money = cnt // 2
	print(money)


import sys
import os
import math
from io import BytesIO, IOBase
from collections import defaultdict, Counter, deque
import heapq
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	s = set(c)
	left = defaultdict(int)
	right = defaultdict(int)
	for j in range(l):
		left[c[j]] += 1
	for j in range(n - r, n):
		right[c[j]] += 1
	ans = 0
	l1 = 0
	oddl = []
	oddr = []
	r1 = 0
	for j in s:
		if left[j] > right[j]:
			left[j] -= right[j]
			del right[j]
			l1 += left[j]
			if left[j] & 1:
				oddl.append(j)
		elif left[j] < right[j]:
			right[j] -= left[j]
			del left[j]
			r1 += right[j]
			if right[j] & 1:
				oddr.append(j)
		else:
			del left[j]
			del right[j]
	if l1 >= r1:
		ans += r1
		for j in oddl:
			if r1:
				left[j] -= 1
				r1 -= 1
			else:
				break
		for j in left:
			if left[j] <= r1:
				r1 -= left[j]
			else:
				left[j] -= r1
				r1 = 0
				ans += left[j] // 2
				if left[j] & 1:
					ans += 1
	else:
		ans += l1
		for j in oddr:
			if l1:
				right[j] -= 1
				l1 -= 1
			else:
				break
		for j in right:
			if right[j] <= l1:
				l1 -= right[j]
			else:
				right[j] -= l1
				l1 = 0
				ans += right[j] // 2
				if right[j] & 1:
					ans += 1
	print(ans)


for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	t = list(map(int, input().split()))
	lc = [0] * (n + 1)
	rc = [0] * (n + 1)
	for i in range(1, n + 1):
		if i <= l:
			lc[t[i - 1]] += 1
		else:
			rc[t[i - 1]] += 1
	for i in range(1, n + 1):
		mn = min(lc[i], rc[i])
		lc[i] -= mn
		rc[i] -= mn
		l -= mn
		r -= mn
	if l < r:
		(l, r) = (r, l)
		(lc, rc) = (rc, lc)
	ans = 0
	for i in range(1, n + 1):
		extra = l - r
		can = lc[i] // 2
		do = min(2 * can, extra)
		ans += do // 2
		l -= do
	ans += (l - r) // 2 + (l + r) // 2
	print(ans)


from collections import Counter
for _ in range(int(input())):
	(n, l, r) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	count = n // 2
	x = abs(l - r) // 2
	c = Counter(a[:l])
	d = Counter(a[l:])
	z = 0
	if l > r:
		(c, d) = (d, c)
	for i in c:
		m = min(c[i], d[i])
		d[i] -= m
		count -= m
	for i in d:
		z += d[i] // 2
	print(count + (x - min(x, z)))


I = lambda : map(int, input().split())
from collections import defaultdict
for t in range(int(input())):
	(n, l, r) = I()
	k = abs(l - r) // 2
	c = I()
	C = defaultdict(lambda : [0, 0])
	for _ in range(l):
		C[next(c)][0] += 1
	for _ in range(r):
		C[next(c)][1] += 1
	d = 0
	L = 0
	R = 0
	for x in C.values():
		dif = x[0] - x[1]
		d += abs(dif)
		if dif >= 0:
			L += dif // 2
		else:
			R += -dif // 2
	print(d // 2 + max(0, k - L) if l >= r else d // 2 + max(0, k - R))


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10 ** 8)
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(300000)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default, func):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	(n, l, r) = map(int, input().split())
	arr = list(map(int, input().split()))
	left = defaultdict(int)
	right = defaultdict(int)
	for i in range(l):
		left[arr[i]] += 1
	for i in range(l, l + r):
		right[arr[i]] += 1
	ans = 0
	for i in left:
		if left[i] >= right[i]:
			left[i] -= right[i]
			right[i] = 0
	for i in right:
		if right[i] > left[i]:
			right[i] -= left[i]
			left[i] = 0
	su = 0
	su1 = 0
	for i in left:
		su += left[i]
	for i in right:
		su1 += right[i]
	if su == su1:
		print(su)
		continue
	elif su > su1:
		su -= su1
		for i in left:
			if su == 0:
				break
			ans += min(su, left[i] // 2 * 2) // 2
			su -= min(su, left[i] // 2 * 2)
		ans += su
		print(ans + su1)
	else:
		cop = su
		su = su1 - su
		for i in right:
			if su == 0:
				break
			ans += min(su, right[i] // 2 * 2) // 2
			su -= min(su, right[i] // 2 * 2)
		ans += su
		print(ans + cop)


import math, sys, bisect, heapq, os
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
pr = lambda x: x

def input():
	return sys.stdin.readline().rstrip('\r\n')
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def solve():
	for _ in range(int(input())):
		(n, l, r) = aj()
		A = aj()
		C1 = Counter(A[:l])
		C2 = Counter(A[l:])
		C3 = C1 & C2
		for i in C3.keys():
			C1[i] -= C3[i]
			C2[i] -= C3[i]
		a = sum(C1.values())
		b = sum(C2.values())
		count = 0
		if a != b:
			req = max(a, b) - (a + b) // 2
			if a > b:
				C3 = C2
				C4 = C1
			else:
				C3 = C1
				C4 = C2
			for i in C4.keys():
				to_move = C4[i] // 2
				to_move = min(to_move, req)
				if to_move > 0:
					C4[i] -= to_move
					C3[i] += to_move
					req -= to_move
					count += to_move
			C5 = C3 & C4
			for i in C5.keys():
				C3[i] -= C5[i]
				C4[i] -= C5[i]
			a = sum(C3.values())
			b = sum(C4.values())
			req = max(a, b) - (a + b) // 2
			if a > b:
				(C3, C4) = (C4, C3)
			if req > 0:
				for i in C4.keys():
					to_move = min(C4[i], req)
					if to_move > 0:
						req -= to_move
						count += to_move
						C4[i] -= to_move
						C3[i] += to_move
			C1 = C3
			C2 = C4
		C3 = C1 & C2
		for i in C3.keys():
			C1[i] -= C3[i]
			C2[i] -= C3[i]
		a = sum(C1.values())
		b = sum(C2.values())
		print(count + min(a, b))
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	from aj import *
except:
	pass
solve()


import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	p = list(map(int, input().split()))
	dl = {}
	dr = {}
	i = 0
	while i < l:
		c = p[i]
		if c in dl:
			dl[c] += 1
		else:
			dl[c] = 1
		i = i + 1
	while i < len(p):
		c = p[i]
		if c in dr:
			dr[c] += 1
		else:
			dr[c] = 1
		i = i + 1
	e1 = []
	e2 = []
	for i in dl:
		if i not in dr:
			e1.append(dl[i])
			dl[i] = 0
	for i in dr:
		if i not in dl:
			e2.append(dr[i])
			dr[i] = 0
	for i in dl:
		if i in dr:
			if dl[i] > dr[i]:
				sub = dl[i] - dr[i]
				if sub != 0:
					e1.append(sub)
			else:
				sub = dr[i] - dl[i]
				if sub != 0:
					e2.append(sub)
	s1 = sum(e1)
	s2 = sum(e2)
	if s1 == s2:
		print(s1)
		continue
	cost = 0
	if s2 > s1:
		c1 = 0
		c2 = 0
		d = s2 - s1
		rem = 0
		for i in range(len(e2)):
			x = e2[i]
			if x > 1:
				toa = min(d, x // 2 * 2)
				d -= toa
				e2[i] -= toa
				cost += toa // 2
		cost += d // 2 * 2
		cost += s1
		print(cost)
		continue
	c1 = 0
	c2 = 0
	d = s1 - s2
	rem = 0
	for i in range(len(e1)):
		x = e1[i]
		if x > 1:
			toa = min(d, x // 2 * 2)
			d -= toa
			e1[i] -= toa
			cost += toa // 2
	cost += d // 2 * 2
	cost += s2
	print(cost)
	continue


from collections import defaultdict
for _ in range(int(input())):
	(n, l, r) = list(map(int, input().split()))
	colour = list(map(int, input().split()))
	left = colour[:l]
	right = colour[l:]
	LeftHT = defaultdict(int)
	rightHT = defaultdict(int)
	for i in left:
		LeftHT[i] += 1
	for i in right:
		rightHT[i] += 1
	needLeft = []
	needRight = []
	for i in LeftHT.keys():
		if i in rightHT and rightHT[i]:
			minVal = min(rightHT[i], LeftHT[i])
			rightHT[i] -= minVal
			LeftHT[i] -= minVal
			if rightHT[i] == 0:
				needRight.append(i)
			if LeftHT[i] == 0:
				needLeft.append(i)
	for i in needLeft:
		del LeftHT[i]
	for i in needRight:
		del rightHT[i]
	if sum(LeftHT.values()) == sum(rightHT.values()):
		print(sum(LeftHT.values()))
	elif sum(LeftHT.values()) > sum(rightHT.values()):
		changeVal = sum(LeftHT.values()) - sum(rightHT.values())
		need = []
		count = 0
		for i in LeftHT.keys():
			if LeftHT[i] and LeftHT[i] >= 2:
				minVal = min(changeVal, 2 * (LeftHT[i] // 2))
				count += minVal // 2
				changeVal -= minVal
				LeftHT[i] -= minVal
				if changeVal == 0:
					break
				if LeftHT[i] == 0:
					need.append(i)
		for i in need:
			del LeftHT[i]
		print(max(sum(LeftHT.values()), sum(rightHT.values())) + count)
	else:
		changeVal = sum(rightHT.values()) - sum(LeftHT.values())
		need = []
		count = 0
		for i in rightHT.keys():
			if rightHT[i] and rightHT[i] >= 2:
				minVal = min(changeVal, 2 * (rightHT[i] // 2))
				count += minVal // 2
				changeVal -= minVal
				rightHT[i] -= minVal
				if rightHT[i] == 0:
					need.append(i)
				if changeVal == 0:
					break
		for i in need:
			del rightHT[i]
		print(max(sum(LeftHT.values()), sum(rightHT.values())) + count)


from collections import Counter
for test in range(int(input())):
	(n, l, r) = (int(i) for i in input().split())
	cost = 0
	w = [int(i) for i in input().split()]
	wl = Counter(w[:l])
	wr = Counter(w[l:])
	for i in wl if sum(wl.values()) <= sum(wr.values()) else wr:
		if i in wl and i in wr:
			m = min(wl[i], wr[i])
			wl[i] -= m
			wr[i] -= m
	(wl, wr) = (+wl, +wr)
	wm = wl if sum(wl.values()) >= sum(wr.values()) else wr
	wc = int(abs(sum(wl.values()) - sum(wr.values())) / 2)
	for i in wm:
		if wm[i] >= 2:
			m = min(int(wm[i] / 2), wc)
			wm[i] -= m * 2
			wc -= m
			cost += m
			if wc == 0:
				break
	wm = +wm
	cost += sum(wm.values())
	print(cost)


import sys
input = sys.stdin.readline
(T,) = map(int, input().split())
for _ in range(T):
	(N, L, R) = map(int, input().split())
	X = list(map(int, input().split()))
	C1 = [0] * N
	C2 = [0] * N
	for i in range(N):
		if i < L:
			C1[X[i] - 1] += 1
		else:
			C2[X[i] - 1] += 1
	if L > R:
		(C2, C1) = (C1, C2)
		(L, R) = (R, L)
	for i in range(N):
		if C1[i] > 0 and C2[i] > 0:
			mn = min(C1[i], C2[i])
			C1[i] -= mn
			C2[i] -= mn
	r = 0
	for i in range(N):
		while R - L > 2 * r and C2[i] > 1:
			r += 1
			C2[i] -= 2
	r += (R - L) // 2 - r
	r += (sum(C1) + sum(C2)) // 2
	print(r)


T = int(input())
for _ in range(T):
	(N, L, R) = map(int, input().split())
	C = list(map(int, input().split()))
	MAX_C = max(C)
	LC = [0 for i in range(MAX_C + 1)]
	RC = [0 for i in range(MAX_C + 1)]
	for i in range(L):
		LC[C[i]] += 1
	for i in range(L, N):
		RC[C[i]] += 1
	for i in range(MAX_C + 1):
		common = min(LC[i], RC[i])
		LC[i] -= common
		RC[i] -= common
		L -= common
		R -= common
	ans = 0
	for i in range(MAX_C + 1):
		if LC[i] > 1 and L > R:
			diff = min((L - R) // 2, LC[i] // 2)
			LC[i] -= diff * 2
			ans += diff
			L -= diff * 2
		elif RC[i] > 1 and R > L:
			diff = min((R - L) // 2, RC[i] // 2)
			RC[i] -= diff * 2
			ans += diff
			R -= diff * 2
	mn = min(L, R)
	ans += mn
	delta = max(L, R) - mn
	ans += delta
	print(ans)


from collections import Counter
t = int(input())
for _ in range(t):
	(n, l, r) = map(int, input().split(' '))
	c = list(map(int, input().split(' ')))
	(cl, cr) = (c[:l], c[l:])
	counter_left = Counter(cl)
	counter_right = Counter(cr)
	difference = {}
	for key in counter_left:
		val = counter_left[key] - counter_right[key]
		if val != 0:
			difference[key] = val
		del counter_right[key]
	for key in counter_right:
		val = counter_left[key] - counter_right[key]
		if val != 0:
			difference[key] = val
	cost = 0
	(pos, neg) = (0, 0)
	for val in difference.values():
		if val > 0:
			pos += abs(val)
		else:
			neg += abs(val)
	if pos == neg:
		print(pos)
		continue
	cost += min(pos, neg)
	match_by_changing_color = min(pos, neg)
	remaining_to_mach = abs(pos - neg)
	impair = 0
	if pos > neg:
		for i in difference.values():
			if i > 0 and i % 2 == 1:
				impair += 1
	else:
		for i in difference.values():
			if i < 0 and i % 2 == 1:
				impair += 1
	if match_by_changing_color > impair:
		impair = 0 if (match_by_changing_color - impair) % 2 == 0 else 1
	else:
		impair -= match_by_changing_color
	cost += impair + (remaining_to_mach - impair) / 2
	print(int(cost))
	continue


from io import BytesIO, IOBase
import sys
import math
import os
from collections import defaultdict
from math import ceil
from bisect import bisect_left, bisect_left
from time import perf_counter
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def mint():
	return map(int, input().split())

def mfloat():
	return map(float, input().split())

def solve():
	(n, l, r) = mint()
	(*a,) = mint()
	left_socks = {}
	right_socks = {}
	for i in range(l):
		left_socks[a[i]] = left_socks.get(a[i], 0) + 1
	for i in range(l, n):
		sock = a[i]
		if left_socks.get(sock, 0) > 0:
			left_socks[sock] -= 1
		else:
			right_socks[sock] = right_socks.get(sock, 0) + 1
	left = sum(left_socks.values())
	right = sum(right_socks.values())
	if left < right:
		pair_up = right_socks.values()
		remaining = right - left
		cost = left
	else:
		pair_up = left_socks.values()
		remaining = left - right
		cost = right
	for i in pair_up:
		pair = i // 2 * 2
		take = min(pair, remaining - remaining % 2)
		cost += take // 2
		remaining -= take
		if not remaining:
			break
	cost += remaining
	print(cost)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


import sys
input = sys.stdin.readline
import math
mod = 10 ** 9 + 7

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	(n, l, r) = invr()
	a = inlt()
	b = []
	for i in range(l, n):
		b.append(a[i])
	a = a[:l]
	a.sort()
	b.sort()
	a1 = [0 for i in range(n)]
	b1 = a1[:]
	for i in range(l):
		a1[a[i] - 1] += 1
	for i in range(r):
		b1[b[i] - 1] += 1
	for i in range(n):
		m = min(a1[i], b1[i])
		a1[i] -= m
		b1[i] -= m
	a = []
	b = []
	for i in range(n):
		for j in range(a1[i]):
			a.append(i + 1)
		for j in range(b1[i]):
			b.append(i + 1)
	l = len(a)
	r = len(b)
	if l < r:
		t = a
		a = b
		b = t
		(l, r) = (r, l)
	a.sort()
	b.sort()
	req = int((l + r) / 2) - r
	c = req
	if req != 0:
		y = []
		x = [[0, i + 1] for i in range(n)]
		for i in range(l):
			x[a[i] - 1][0] += 1
		x.sort(key=lambda x: x[0])
		x.reverse()
		g = n - 1
		for i in range(n):
			if x[i][0] == 0:
				g = i - 1
				break
		p = 0
		while req > 0:
			t = req
			req = max(req - x[p][0] // 2, 0)
			for i in range(t - req):
				y.append(x[p][1])
			if p == n - 1:
				for i in range(req):
					req -= 1
					y.append(x[g - i][1])
			p += 1
		for i in y:
			b.append(i)
		y.sort()
		h = [1 for i in range(l)]
		p = 0
		g = len(y)
		for i in range(l):
			if a[i] == y[p]:
				h[i] = 0
				if p == g - 1:
					break
				p += 1
		t = []
		for i in range(l):
			if h[i] == 1:
				t.append(a[i])
		a = t
	a.sort()
	b.sort()
	p = 0
	x = 0
	d = [0 for i in range(n)]
	n = l + r
	for i in range(int(n / 2)):
		d[a[i] - 1] += 1
	for i in range(int(n / 2)):
		if d[b[i] - 1] != 0:
			d[b[i] - 1] -= 1
	print(c + sum(d))


import sys
from math import *
import threading
from itertools import count
from pprint import pprint
from collections import defaultdict
from heapq import heapify, heappop, heappush
sys.setrecursionlimit(300000)
mod = 10 ** 9 + 7
inf = 10 ** 15
decision = ['NO', 'YES']
yes = 'YES'
no = 'NO'
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def npr(n, r):
	return factorial(n) % mod // (factorial(n - r) % mod) if n >= r else 0

def ncr(n, r):
	return factorial(n) % mod // (factorial(r) % mod * (factorial(n - r) % mod)) if n >= r else 0

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [{1, i} for i in range(n + 1)]
	p = 2
	while p <= n:
		for i in range(p * 2, n + 1, p):
			prime[i].add(p)
		p += 1
	return prime

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def prod(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def sumk(a, b):
	print('called for', a, b)
	ans = a * (a + 1) // 2
	ans -= b * (b + 1) // 2
	return ans

def sumi(n):
	ans = 0
	if len(n) > 1:
		for x in n:
			ans += int(x)
		return ans
	else:
		return int(n)
karmanya = int(input())
while karmanya != 0:
	karmanya -= 1
	(n, l, r) = map(int, input().split())
	a = list(map(int, input().split()))
	left = [0] * (n + 1)
	right = [0] * (n + 1)
	for i in range(n):
		if i < l:
			left[a[i]] += 1
		else:
			right[a[i]] += 1
	for i in range(n + 1):
		x = min(left[i], right[i])
		l -= x
		r -= x
		left[i] -= x
		right[i] -= x
	if l <= r:
		ans = l
		diff = r - l
		for i in range(n + 1):
			pair = min(diff // 2, right[i] // 2)
			ans += pair
			diff -= 2 * pair
			right[i] -= 2 * pair
		ans += diff
	else:
		ans = r
		diff = l - r
		for i in range(n + 1):
			pair = min(diff // 2, left[i] // 2)
			ans += pair
			diff -= 2 * pair
			left[i] -= 2 * pair
		ans += diff
	print(ans)


T = int(input())
t = 1
while t <= T:
	(n, l, r) = map(int, input().split())
	arr = list(map(int, input().split()))
	dic1 = {}
	dic2 = {}
	for i in range(l):
		if arr[i] not in dic1:
			dic1[arr[i]] = 0
		dic1[arr[i]] += 1
	for j in range(l, n):
		if arr[j] not in dic2:
			dic2[arr[j]] = 0
		dic2[arr[j]] += 1
	for e in dic1:
		if e in dic2:
			minimum = min(dic1[e], dic2[e])
			dic1[e] -= minimum
			dic2[e] -= minimum
	lefttot = 0
	leftodd = 0
	righttot = 0
	rightodd = 0
	for e in dic1:
		if dic1[e] > 0:
			if dic1[e] % 2 == 1:
				leftodd += 1
			lefttot += dic1[e]
	for e in dic2:
		if dic2[e] > 0:
			if dic2[e] % 2 == 1:
				rightodd += 1
			righttot += dic2[e]
	if lefttot <= righttot:
		color = lefttot
		extra = max(0, rightodd - color)
		direc = (righttot - lefttot) // 2
	else:
		color = righttot
		extra = max(0, leftodd - color)
		direc = (lefttot - righttot) // 2
	ans = color + extra // 2 + direc
	print(ans)
	t += 1


from bisect import bisect, bisect_left
from collections import *
from heapq import *
from math import gcd, ceil, sqrt, floor, inf
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

def A(n):
	return [0] * n

def AI(n, x):
	return [x] * n

def A2(n, m):
	return [[0] * m for i in range(n)]

def G(n):
	return [[] for i in range(n)]

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
mod = 10 ** 9 + 7
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	fact(x, mod)
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa.reverse()

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def floorsum(a, b, c, n):
	if a == 0:
		return b // c * (n + 1)
	if a >= c or b >= c:
		return floorsum(a % c, b % c, c, n) + b // c * (n + 1) + a // c * n * (n + 1) // 2
	m = (a * n + b) // c
	return n * m - floorsum(c, c - b - 1, a, m - 1)

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

def lowbit(n):
	return n & -n

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class ST:

	def __init__(self, arr):
		n = len(arr)
		mx = n.bit_length()
		self.st = [[0] * mx for i in range(n)]
		for i in range(n):
			self.st[i][0] = arr[i]
		for j in range(1, mx):
			for i in range(n - (1 << j) + 1):
				self.st[i][j] = max(self.st[i][j - 1], self.st[i + (1 << j - 1)][j - 1])

	def query(self, l, r):
		if l > r:
			return -inf
		s = (r + 1 - l).bit_length() - 1
		return max(self.st[l][s], self.st[r - (1 << s) + 1][s])

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] > self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

class UF:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n
		self.size = AI(n, 1)
		self.edge = A(n)

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			self.edge[pu] += 1
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			self.edge[pu] += self.edge[pv] + 1
			self.size[pu] += self.size[pv]
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv
			self.edge[pv] += self.edge[pu] + 1
			self.size[pv] += self.size[pu]

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return flag

def dij(s, graph):
	d = AI(n, inf)
	d[s] = 0
	heap = [(0, s)]
	vis = A(n)
	while heap:
		(dis, u) = heappop(heap)
		if vis[u]:
			continue
		vis[u] = 1
		for (v, w) in graph[u]:
			if d[v] > d[u] + w:
				d[v] = d[u] + w
				heappush(heap, (d[v], v))
	return d

def bell(s, g):
	dis = AI(n, inf)
	dis[s] = 0
	for i in range(n - 1):
		for (u, v, w) in edge:
			if dis[v] > dis[u] + w:
				dis[v] = dis[u] + w
	change = A(n)
	for i in range(n):
		for (u, v, w) in edge:
			if dis[v] > dis[u] + w:
				dis[v] = dis[u] + w
				change[v] = 1
	return dis

def lcm(a, b):
	return a * b // gcd(a, b)

def lis(nums):
	res = []
	for k in nums:
		i = bisect.bisect_left(res, k)
		if i == len(res):
			res.append(k)
		else:
			res[i] = k
	return len(res)

def RP(nums):
	n = len(nums)
	s = set(nums)
	d = {}
	for (i, k) in enumerate(sorted(s), 1):
		d[k] = i
	bi = BIT([0] * (len(s) + 1))
	ans = 0
	for i in range(n - 1, -1, -1):
		ans += bi.query(d[nums[i]] - 1)
		bi.update(d[nums[i]], 1)
	return ans

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def nb(i, j, n, m):
	for (ni, nj) in [[i + 1, j], [i - 1, j], [i, j - 1], [i, j + 1]]:
		if 0 <= ni < n and 0 <= nj < m:
			yield (ni, nj)

def topo(n):
	q = deque()
	res = []
	for i in range(1, n + 1):
		if ind[i] == 0:
			q.append(i)
			res.append(i)
	while q:
		u = q.popleft()
		for v in g[u]:
			ind[v] -= 1
			if ind[v] == 0:
				q.append(v)
				res.append(v)
	return res

@bootstrap
def gdfs(r, p):
	for ch in g[r]:
		if ch != p:
			yield gdfs(ch, r)
	yield None
from random import randint
t = N()
for i in range(t):
	(n, l, r) = RL()
	c = RLL()
	L = Counter()
	for i in range(l):
		L[c[i]] += 1
	ans = 0
	R = Counter()
	for i in range(l, n):
		if c[i] in L:
			L[c[i]] -= 1
			if L[c[i]] == 0:
				del L[c[i]]
		else:
			R[c[i]] += 1
	cl = sum(L.values())
	cr = sum(R.values())
	if cl >= cr:
		ans += cr
		cl -= cr
		ma = 0
		for v in L.values():
			ma += v // 2 * 2
		if ma >= cl:
			ans += cl // 2
		else:
			ans += ma // 2 + (cl - ma)
	else:
		ans += cl
		cr -= cl
		ma = 0
		for v in R.values():
			ma += v // 2 * 2
		if ma >= cr:
			ans += cr // 2
		else:
			ans += ma // 2 + (cr - ma)
	print(ans)


from math import floor
from math import sqrt
from math import ceil
from itertools import combinations, accumulate, groupby, count
from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from os import *
from re import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))

def fast():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in fast().split()]
(z, zz) = (fast, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer, end='\n'):
	stdout.write(str(answer) + end)
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
num = int(z())
for _ in range(num):
	(n, l, r) = zzz()
	arr = zzz()
	if l > r:
		(l, r) = (r, l)
		arr = arr[::-1]
	left = []
	right = []
	cntLeft = {}
	cntRight = {}
	setArr = set()
	for i in range(n):
		if i < l:
			left.append(arr[i])
		else:
			right.append(arr[i])
		cntLeft[arr[i]] = 0
		cntRight[arr[i]] = 0
		setArr.add(arr[i])
	for i in left:
		cntLeft[i] += 1
	for j in right:
		cntRight[j] += 1
	ans = 0
	ex = 0
	for i in setArr:
		x = cntLeft[i]
		y = cntRight[i]
		ans += min(x, y)
		cntRight[i] -= min(x, y)
		cntLeft[i] -= min(x, y)
		ex += cntRight[i] // 2
	want = n // 2
	need = want - ans
	cost = need + max(0, want - min(l, r) - ex)
	print(cost)


from sys import stdin, stdout
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor

def fun(dr, temp):
	odd = 0
	for i in dr.keys():
		if dr[i] & 1:
			odd += 1
	if odd >= temp:
		for i in dr.keys():
			if dr[i] & 1 and temp:
				dr[i] -= 1
				temp -= 1
	else:
		for i in dr.keys():
			if dr[i] & 1 and temp:
				dr[i] -= 1
				temp -= 1
		for i in dr.keys():
			if temp:
				if temp >= dr[i]:
					temp -= dr[i]
					dr[i] = 0
				else:
					dr[i] -= temp
					temp = 0
			else:
				break

def fun2(dr):
	x = 0
	ans = 0
	for i in dr.keys():
		if dr[i] and (not dr[i] & 1):
			ans += dr[i] // 2
		elif dr[i] and dr[i] & 1:
			if x:
				ans += dr[i] // 2
				ans += 2
				x = 0
			else:
				ans += dr[i] // 2
				x = 1
	return ans
for _ in range(it()):
	(n, l, r) = mp()
	a = mp()
	left = a[:l]
	right = a[l:]
	dl = C(left)
	dr = C(right)
	for i in range(1, n + 1):
		if dr[i] and dl[i]:
			temp = min(dl[i], dr[i])
			dl[i] -= temp
			dr[i] -= temp
	ans = min(sum(dl.values()), sum(dr.values()))
	temp = ans
	if ans == sum(dl.values()):
		fun(dr, temp)
		print(ans + fun2(dr))
	else:
		fun(dl, temp)
		print(ans + fun2(dl))


import sys
import math
from collections import defaultdict
mod = 10 ** 9 + 7
LI = lambda : [int(k) for k in input().split()]
input = lambda : sys.stdin.readline().rstrip()
IN = lambda : int(input())
S = lambda : input()
for t in range(IN()):
	(n, l, r) = LI()
	c = LI()
	ldd = defaultdict(int)
	rdd = defaultdict(int)
	ll = 0
	rr = 0
	for i in range(n):
		if i < l:
			ldd[c[i]] += 1
		else:
			rdd[c[i]] += 1
	sc = set(c)
	for ele in sc:
		it = min(ldd[ele], rdd[ele])
		ldd[ele] -= it
		rdd[ele] -= it
		l -= it
		r -= it
	ans = 0
	if l > r:
		for ele in sc:
			it = ldd[ele] // 2
			ans += min(it, (l - r) // 2)
			l -= it * 2
			if l <= r:
				break
	elif r > l:
		for ele in sc:
			it = rdd[ele] // 2
			ans += min(it, (r - l) // 2)
			r -= it * 2
			if r <= l:
				break
	ans += max(l, r)
	print(ans)


from io import BytesIO, IOBase
from math import sqrt
import sys, os
from os import path
inpl = lambda : list(map(int, input().split()))
inpm = lambda : map(int, input().split())
inpi = lambda : int(input())
inp = lambda : input()
(rev, ra, l) = (reversed, range, len)
P = print
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def B(n):
	return bin(n).replace('0b', '')

def factors(n):
	arr = []
	for i in ra(2, int(sqrt(n)) + 1):
		if n % i == 0:
			arr.append(i)
			if i * i != n:
				arr.append(int(n / i))
	return arr

def dfs(arr, n):
	pairs = [[i + 1] for i in ra(n)]
	vis = [0] * (n + 1)
	for i in ra(l(arr)):
		pairs[arr[i][0] - 1].append(arr[i][1])
	pairs[arr[i][1] - 1].append(arr[i][0])
	comp = []
	for i in ra(n):
		stack = [pairs[i]]
		temp = []
		if vis[stack[-1][0]] == 0:
			while len(stack) > 0:
				if vis[stack[-1][0]] == 0:
					temp.append(stack[-1][0])
					vis[stack[-1][0]] = 1
					s = stack.pop()
					for j in s[1:]:
						if vis[j] == 0:
							stack.append(pairs[j - 1])
				else:
					stack.pop()
			comp.append(temp)
	return comp
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys, operator, math, operator
from collections import Counter
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import random
tc = inpi()
while tc:
	tc -= 1
	(n, l, r) = inpm()
	li = inpl()
	(left, right) = ([0] * (n + 1), [0] * (n + 1))
	if r > l:
		for i in ra(l):
			left[li[i]] += 1
		for j in ra(l, n):
			right[li[j]] += 1
	else:
		for i in ra(l):
			right[li[i]] += 1
		for j in ra(l, n):
			left[li[j]] += 1
		(l, r) = (r, l)
	for i in ra(n + 1):
		mi = min(left[i], right[i])
		(left[i], right[i]) = (left[i] - mi, right[i] - mi)
		(r, l) = (r - mi, l - mi)
	ans = 0
	for i in ra(n + 1):
		mi = min((r - l) // 2, right[i] // 2)
		ans += mi
		r -= mi * 2
	P(ans + r)


from collections import Counter

def solve():
	(n, l, r) = map(int, input().split())
	lst = list(map(int, input().split()))
	(left, right) = (lst[:l], lst[l:])
	(cnt_l, cnt_r) = (Counter(left), Counter(right))
	if r > l:
		(l, r) = (r, l)
		(cnt_l, cnt_r) = (cnt_r, cnt_l)
	for i in cnt_r:
		x = min(cnt_r[i], cnt_l.get(i, 0))
		cnt_r[i] -= x
		cnt_l[i] = cnt_l.get(i, 0) - x
	(add, ans) = ((l - r) // 2, 0)
	for i in cnt_l:
		t = cnt_l[i] // 2
		if t >= add:
			cnt_l[i] -= 2 * add
			ans += add
			add = 0
			break
		cnt_l[i] -= 2 * t
		add -= t
		ans += t
	ans += (sum(cnt_l.values()) + sum(cnt_r.values())) // 2 + add
	print(ans)
for test in range(int(input())):
	solve()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	left = [0 for __ in range(n)]
	right = [0 for __ in range(n)]
	a = list(map(int, input().split()))
	for i in range(l):
		left[a[i] - 1] += 1
	for i in range(l, n):
		right[a[i] - 1] += 1
	for i in range(n):
		min_cnt = min(left[i], right[i])
		left[i] -= min_cnt
		right[i] -= min_cnt
		l -= min_cnt
		r -= min_cnt
	ans = 0
	if l < r:
		(l, r) = (r, l)
		(left, right) = (right, left)
	for i in range(n):
		extra = l - r
		can_do = left[i] // 2
		do = min(can_do * 2, extra)
		ans += do // 2
		l -= do
	ans += (l - r) // 2 + (l + r) // 2
	print(ans)


import sys, os.path
from collections import defaultdict
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	left = defaultdict(int)
	right = defaultdict(int)
	for i in range(n):
		if i + 1 <= l:
			left[c[i]] += 1
		elif left[c[i]] > 0:
			left[c[i]] -= 1
		else:
			right[c[i]] += 1
	ans = 0
	rr = 0
	ll = 0
	for i in left:
		ll += left[i]
	for i in right:
		rr += right[i]
	ans += min(rr, ll)
	if rr > ll:
		k = ll
		for i in right:
			if k == 0:
				break
			if right[i] % 2 != 0:
				right[i] -= 1
				k -= 1
		for i in right:
			if k == 0:
				break
			if right[i] % 2 == 0:
				p = min(k, right[i])
				k -= p
				right[i] -= p
		odd = 0
		even = 0
		for i in right:
			odd += right[i] % 2
			even += right[i] // 2
		ans += even
		ans += odd
	elif ll > rr:
		k = rr
		for i in left:
			if k == 0:
				break
			if left[i] % 2 != 0:
				k -= 1
				left[i] -= 1
		for i in left:
			if k == 0:
				break
			if left[i] % 2 == 0:
				p = min(k, left[i])
				k -= p
				left[i] -= p
		odd = 0
		even = 0
		for i in left:
			odd += left[i] % 2
			even += left[i] // 2
		ans += even
		ans += odd
	print(ans)


from collections import Counter
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	nums = list(map(int, input().split()))
	ls = Counter(nums[:l])
	rs = Counter(nums[l:])
	common = ls & rs
	ls -= common
	rs -= common
	ans = 0
	(len_ls, len_rs) = (0, 0)
	len_ls = sum(ls.values())
	len_rs = sum(rs.values())
	if len_ls > len_rs:
		(len_ls, len_rs) = (len_rs, len_ls)
		(ls, rs) = (rs, ls)
	ans += len_ls
	odd_rs = 0
	for i in rs:
		if rs[i] & 1:
			odd_rs += 1
	even_rs = sum(rs.values()) - odd_rs
	if len_ls < odd_rs:
		ans += even_rs // 2 + (odd_rs - len_ls)
	else:
		extra = len_ls - odd_rs
		ans += (even_rs - extra) // 2
	print(ans)


t = int(input())
for tk in range(t):
	(n, l, r) = map(int, input().split())
	c = list(map(int, input().split()))
	d1 = {}
	d2 = {}
	for i in range(l):
		d1[c[i]] = d1.get(c[i], 0) + 1
	for i in range(l, n):
		d2[c[i]] = d2.get(c[i], 0) + 1
	for i in d1.keys():
		x = min(d1[i], d2.get(i, 0))
		d1[i] = d1[i] - x
		d2[i] = d2.get(i, 0) - x
	v1 = d1.values()
	v2 = d2.values()
	s1 = sum(v1)
	s2 = sum(v2)
	s = abs(s1 - s2)
	s = s // 2
	if s == 0:
		print(s1)
	else:
		ans = max(s1, s2)
		if s1 > s2:
			for i in d1:
				a = d1[i] // 2
				if s - a >= 0:
					ans -= a
					s -= a
				else:
					ans -= s
					break
				if s == 0:
					break
			print(ans)
		else:
			for i in d2:
				a = d2[i] // 2
				if s - a >= 0:
					ans -= d2[i] // 2
					s -= d2[i] // 2
				else:
					ans -= s
					break
				if s == 0:
					break
			print(ans)


from collections import Counter
for _ in range(int(input())):
	(n, l, r) = [int(t) for t in input().split()]
	a = [int(t) for t in input().split()]
	L = Counter(a[:l])
	R = Counter(a[l:])
	for k in L:
		paired = min(L[k], R[k])
		L[k] -= paired
		R[k] -= paired
		l -= paired
		r -= paired
	l_single = sum((v % 2 for v in L.values()))
	l_pair = l - l_single
	r_single = sum((v % 2 for v in R.values()))
	r_pair = r - r_single
	paired = min(l_single, r_single)
	l_single -= paired
	r_single -= paired
	ans = paired
	if l_single == 0:
		(l_single, l_pair, r_single, r_pair) = (r_single, r_pair, l_single, l_pair)
	paired = min(l_single, r_pair)
	l_single -= paired
	r_pair -= paired
	ans += paired
	ans += l_single + l_pair // 2 + r_pair // 2
	print(ans)


from collections import Counter
import sys

def read_ints():
	return map(int, sys.stdin.readline().split())

def find_min_cost(left_colors, right_colors):
	l = left_colors
	r = right_colors
	if len(l) < len(r):
		(l, r) = (r, l)
	assert len(l) >= len(r)
	l = Counter(l)
	r = Counter(r)
	common = l & r
	l -= common
	r -= common
	n_to_move = (sum(l.values()) - sum(r.values())) // 2
	assert n_to_move >= 0
	cost = 0
	for (color, count) in tuple(l.most_common()):
		while n_to_move != 0:
			if count < 2:
				break
			count -= 2
			l[color] -= 2
			cost += 1
			n_to_move -= 1
	l_len = sum(l.values())
	r_len = sum(r.values())
	cost += n_to_move
	l_len -= n_to_move
	r_len += n_to_move
	assert l_len == r_len
	cost += l_len
	return cost

def main():
	(t_n,) = read_ints()
	for i_t in range(t_n):
		(n, l, r) = read_ints()
		c_seq = tuple(read_ints())
		(left, right) = (c_seq[:l], c_seq[l:])
		assert len(left) == l and len(right) == r and (l + r == n)
		result = find_min_cost(left, right)
		print(result)
main()


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	c = dict(Counter(l))
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def fun(n):
	if math.sqrt(n) == int(math.sqrt(n)):
		return 1
	return 0

def find(v, parent):
	if v == parent[v]:
		return v
	parent[v] = find(parent[v], parent)
	return parent[v]

def union(a, b, parent):
	a = find(a, parent)
	b = find(b, parent)
	if a != b:
		if parent[b] < parent[a]:
			parent[a] = parent[b]
			return 1
		else:
			parent[b] = parent[a]
			return 0

def solve():
	(n, l, r) = li()
	socks = li()
	ls = socks[:l]
	rs = socks[l:]
	if l > r:
		(l, r) = (r, l)
		s = ls[:]
		ls = rs[:]
		rs = s[:]
	toShift = (r - l) // 2
	d = defaultdict(lambda : 0)
	for i in rs:
		d[i] += 1
	d1 = defaultdict(lambda : 0)
	for i in ls:
		d1[i] += 1
	for i in list(list(d1.keys()) + list(d.keys())):
		m = min(d[i], d1[i])
		d[i] -= m
		d1[i] -= m
		l -= m
		r -= m
	toShift = (r - l) // 2
	ans = toShift
	cnt = 0
	for i in d.keys():
		x = d[i] // 2
		m = min(x, toShift)
		d[i] -= m
		toShift -= m
		cnt += m
		if toShift == 0:
			break
	ans = ans + (l + r) // 2 - cnt
	print(ans)
t = 1
t = int(input())
for _ in range(t):
	solve()


import math

def ints():
	return map(int, input().split())
for _ in range(int(input())):
	(n, l, r) = ints()
	s = list(ints())
	sl = s[:l]
	sr = s[l:]
	fl = [0] * (n + 1)
	fr = [0] * (n + 1)
	for i in sl:
		fl[i] += 1
	for i in sr:
		fr[i] += 1
	ans = 0
	for i in range(1, n + 1):
		if fl[i] > fr[i]:
			fl[i] -= fr[i]
			fr[i] = 0
		else:
			fr[i] -= fl[i]
			fl[i] = 0
	tl = sum(fl)
	tr = sum(fr)
	if tl > tr:
		i = 1
		while i <= n and tl > tr:
			temp = min(fl[i] // 2, math.ceil((tl - tr) / 2))
			ans += temp
			fl[i] -= temp * 2
			tl -= temp * 2
			i += 1
	else:
		i = 1
		while i <= n and tr > tl:
			temp = min(fr[i] // 2, math.ceil((tr - tl) / 2))
			ans += temp
			fr[i] -= temp * 2
			tr -= temp * 2
			i += 1
	ans += max(tl, tr)
	print(ans)


import bisect
import collections
import functools
import heapq
import itertools
import math
import random
import sys
input = sys.stdin.readline
ri = lambda : int(input())
rf = lambda : list(map(float, input().split()))
rl = lambda : list(map(int, input().split()))
rs = lambda : input().rstrip()
MOD = 10 ** 9 + 7
INF = float('inf')

def solve_case():
	(n, l, r) = rl()
	c = rl()
	(cnt_left, cnt_right) = ([0] * (n + 1), [0] * (n + 1))
	for i in range(n):
		if i < l:
			cnt_left[c[i]] += 1
		else:
			cnt_right[c[i]] += 1
	if l > r:
		(l, r) = (r, l)
		(cnt_left, cnt_right) = (cnt_right, cnt_left)
	(left_remain, right_remain) = (l, r)
	for ci in range(1, n + 1):
		common = min(cnt_left[ci], cnt_right[ci])
		cnt_left[ci] -= common
		cnt_right[ci] -= common
		left_remain -= common
		right_remain -= common
	res = 0
	for ci in range(1, n + 1):
		need = min(max((right_remain - left_remain) // 2, 0), cnt_right[ci] // 2)
		res += need
		right_remain -= need * 2
	res += right_remain
	print(res)
T = ri()
for ti in range(1, T + 1):
	solve_case()


import os, sys, math
from io import BytesIO, IOBase
from collections import defaultdict, deque, OrderedDict
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

def I():
	return int(input())

def In():
	return map(int, input().split())

def ln():
	return list(map(int, input().split()))

def Sn():
	return input().strip()
from heapq import heappop, heappush
BUFSIZE = 8192

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def solve():
	(n, l1, r1) = In()
	l = list(In())
	left = {}
	right = {}
	for i in range(l1):
		if left.get(l[i], -1) != -1:
			left[l[i]] += 1
		else:
			left[l[i]] = 1
	for i in range(l1, n):
		if right.get(l[i], -1) != -1:
			right[l[i]] += 1
		else:
			right[l[i]] = 1
	ans = 0
	(lex, rix) = ([], [])
	for x in left:
		if right.get(x, -1) != -1:
			ok = min(left[x], right[x])
			right[x] -= ok
			left[x] -= ok
			if right[x] == 0:
				rix.append(x)
			if left[x] == 0:
				lex.append(x)
	for x in lex:
		left.pop(x)
	for x in rix:
		right.pop(x)
	(le, ri) = (0, 0)
	for x in left:
		le += left[x]
	for x in right:
		ri += right[x]
	op = min(le, ri)
	if le == op:
		ans += op
		left.clear()
		pq = []
		t = list(right.keys())
		for x in t:
			if right[x] & 1 == 1:
				heappush(pq, [0, x, right[x]])
			else:
				heappush(pq, [1, x, right[x]])
		for i in range(op):
			t = heappop(pq)
			right[t[1]] -= 1
			t[0] ^= 1
			t[2] -= 1
			if t[2] != 0:
				heappush(pq, t)
	else:
		right.clear()
		ans += op
		pq = []
		t = list(left.keys())
		for x in t:
			if left[x] & 1 == 1:
				heappush(pq, [0, x, left[x]])
			else:
				heappush(pq, [1, x, left[x]])
		j = 0
		for i in range(op):
			t = heappop(pq)
			left[t[1]] -= 1
			t[0] ^= 1
			t[2] -= 1
			if t[2] != 0:
				heappush(pq, t)
	(lex, rix) = ([], [])
	for x in right:
		if right[x] >= 2:
			ans += right[x] // 2
			right[x] %= 2
			if right[x] == 0:
				rix.append(x)
	for x in rix:
		right.pop(x)
	for x in left:
		if left[x] >= 2:
			ans += left[x] // 2
			left[x] %= 2
			if left[x] == 0:
				lex.append(x)
	for x in lex:
		left.pop(x)
	(le, ri) = (0, 0)
	for x in left:
		le += left[x]
	for x in right:
		ri += right[x]
	if le:
		ans += le
	elif ri:
		ans += ri
	print(ans)
	pass

def main():
	T = I()
	for i in range(T):
		solve()
M = 998244353
P = 1000000007

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import Counter
for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	line = list(map(int, input().split()))
	lr = abs(l - r) // 2
	x = n // 2
	s = Counter(line)
	res = 0
	a = Counter(line[:l])
	b = Counter(line[l:])
	if l > r:
		(r, l) = (l, r)
		(a, b) = (b, a)
	for i in a:
		num = min(a[i], b[i])
		a[i] -= num
		b[i] -= num
		x -= num
	for el in b:
		res += b[el] // 2
	print(x + (lr - min(lr, res)))


def sign(x):
	return 1 if x > 0 else -1

def main():
	t = int(input())
	for _ in range(t):
		(n, l, r) = map(int, input().split())
		c = list(map(int, input().split()))
		d = {}
		for i in range(n):
			if c[i] not in d:
				if i < l:
					d[c[i]] = 1
				else:
					d[c[i]] = -1
			elif i < l:
				d[c[i]] += 1
			else:
				d[c[i]] -= 1
		total = 0
		cnt = ab_cnt = 0
		for k in d:
			cnt += d[k]
			ab_cnt += abs(d[k])
		sc = sign(cnt)
		ab = abs(cnt)
		for k in d:
			if d[k] == 0:
				continue
			if sc == sign(d[k]):
				goods = abs(d[k]) // 2 * 2
				if goods >= ab:
					d[k] -= ab * sign(d[k])
					total += ab // 2
					ab_cnt -= ab
					ab = 0
					break
				else:
					d[k] -= goods * sign(d[k])
					ab -= goods
					total += goods // 2
					ab_cnt -= goods
		total += ab
		ab_cnt -= ab
		total += ab_cnt // 2
		print(total)
main()


import sys

def solve(N, L, R, A):
	my_dict = {}
	for a in A:
		my_dict[a] = [0, 0]
	for i in range(L):
		my_dict[A[i]][0] += 1
	for i in range(L, N):
		my_dict[A[i]][1] += 1
	mks = list(my_dict.keys())
	recolor = 0
	for mk in mks:
		recolor += abs(my_dict[mk][0] - my_dict[mk][1])
	recolor /= 2
	if L < R:
		imbalance = (R - L) / 2
		fixable = 0
		for mk in mks:
			if my_dict[mk][1] - my_dict[mk][0] > 0:
				fixable += (my_dict[mk][1] - my_dict[mk][0]) // 2
	else:
		imbalance = (L - R) / 2
		fixable = 0
		for mk in mks:
			if my_dict[mk][0] - my_dict[mk][1] > 0:
				fixable += (my_dict[mk][0] - my_dict[mk][1]) // 2
	plus = imbalance - fixable
	if plus > 0:
		recolor += plus
	print(int(recolor))

def run():
	out = ''
	T = int(input())
	for i in range(T):
		(N, L, R) = [int(x) for x in sys.stdin.readline().split()]
		A = [int(x) for x in sys.stdin.readline().split()]
		solve(N, L, R, A)
run()


from collections import Counter

def solve(arr, brr):
	mp = Counter()
	for x in arr:
		mp[x] += 1
	for x in brr:
		mp[x] -= 1
	cntL = pairedL = cntR = pairedR = 0
	for f in mp.values():
		if f > 0:
			cntL += f
			pairedL += f - (f & 1)
		else:
			f = -f
			cntR += f
			pairedR += f - (f & 1)
	res = 0
	if cntL < cntR:
		(cntL, pairedL, cntR, pairedR) = (cntR, pairedR, cntL, pairedL)
	delta = cntL - cntR
	x = min(delta - (delta & 1), pairedL)
	res += x // 2
	cntL -= x
	res += (cntL - cntR) // 2
	res += (cntL + cntR) // 2
	return res
for _ in range(int(input())):
	(_, l, _) = map(int, input().split())
	u = list(map(int, input().split()))
	(arr, brr) = (u[:l], u[l:])
	print(solve(arr, brr))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
tests = inp()
for _ in range(tests):
	(n, l, r) = invr()
	c = inlt()
	colourCount = [[0, 0] for _ in range(n)]
	for ii in range(l):
		colourCount[c[ii] - 1][0] += 1
	for ii in range(l, n):
		colourCount[c[ii] - 1][1] += 1
	totalCost = 0
	spareLeft = 0
	spareRight = 0
	for col in colourCount:
		matches = min(col)
		col[0] -= matches
		col[1] -= matches
		if l > r:
			matches = min(col[0] // 2, (l - r) // 2)
			l -= matches
			r += matches
			col[0] -= matches * 2
			totalCost += matches
		elif r > l:
			matches = min(col[1] // 2, (r - l) // 2)
			l += matches
			r -= matches
			col[1] -= matches * 2
			totalCost += matches
		matches = min(col[0], spareRight)
		spareRight -= matches
		col[0] -= matches
		spareLeft += col[0]
		totalCost += matches
		matches = min(col[1], spareLeft)
		spareLeft -= matches
		col[1] -= matches
		spareRight += col[1]
		totalCost += matches
	totalCost += spareLeft + spareRight
	print(totalCost)


for _ in range(int(input())):
	(n, l, r) = map(int, input().split())
	arr = list(map(int, input().split()))
	dictl = {}
	for i in range(l):
		if dictl.get(arr[i]) is None:
			dictl[arr[i]] = 0
		dictl[arr[i]] = dictl[arr[i]] + 1
	dictr = {}
	for i in range(l, n):
		if dictr.get(arr[i]) is None:
			dictr[arr[i]] = 0
		dictr[arr[i]] = dictr[arr[i]] + 1
	for k in dictl.keys():
		if dictr.get(k) is None:
			continue
		mini = min(dictl[k], dictr[k])
		dictl[k] -= mini
		dictr[k] -= mini
		r -= mini
		l -= mini
	res = min(l, r)
	if l < r:
		diff = (r - l) // 2
		for k in dictr.keys():
			if diff == 0:
				break
			m = min(diff, dictr[k] // 2)
			res += m
			diff -= m
		res += diff * 2
	else:
		diff = (l - r) // 2
		for k in dictl.keys():
			if diff == 0:
				break
			m = min(diff, dictl[k] // 2)
			res += m
			diff -= m
		res += diff * 2
	print(res)


for _ in range(int(input())):
	(n, left, right) = [int(x) for x in input().split()]
	all = [int(x) for x in input().split()]
	from collections import defaultdict
	r = defaultdict(int)
	l = defaultdict(int)
	for x in all[left:]:
		r[x] += 1
	for x in all[:left]:
		l[x] += 1
	sl = 0
	sr = 0
	steps = 0
	for x in range(1, n + 1):
		m = min(l[x], r[x])
		left -= m
		right -= m
		l[x] -= m
		r[x] -= m
		sl += l[x] // 2
		sr += r[x] // 2
	m = min(left, right)
	steps += m
	left -= m
	right -= m
	if left == 0:
		if sr * 2 > right:
			steps += right // 2
		else:
			steps += right - sr * 2 + sr
	elif sl * 2 > left:
		steps += left // 2
	else:
		steps += left - sl * 2 + sl
	print(steps)


from collections import defaultdict
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	ll = list(map(int, input().split()))
	l = defaultdict(int)
	r = defaultdict(int)
	for i in range(m):
		l[ll[i]] += 1
	for i in range(m, n):
		r[ll[i]] += 1
	for i in l:
		if r[i] > 0:
			c = min(r[i], l[i])
			l[i] -= c
			r[i] -= c
	if m < x:
		k = (x - m) // 2
		ans = 0
		for i in r:
			if k == 0:
				break
			if r[i] > 1:
				c = k
				ans += min(k, r[i] // 2)
				k -= min(k, r[i] // 2)
				r[i] -= 2 * min(c, r[i] // 2)
		if k > 0:
			for i in r:
				if k == 0:
					break
				l[i] += 1
				r[i] -= 1
				ans += 1
				k -= 1
		for i in r:
			ans += r[i]
	else:
		k = (m - x) // 2
		ans = 0
		for i in l:
			if k == 0:
				break
			if l[i] > 1:
				c = k
				ans += min(k, l[i] // 2)
				k -= min(k, l[i] // 2)
				l[i] -= 2 * min(c, l[i] // 2)
		if k > 0:
			for i in r:
				if k == 0:
					break
				r[i] += 1
				l[i] -= 1
				ans += 1
				k -= 1
		for i in l:
			ans += l[i]
	print(ans)