Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. 

Chef spent N days working really hard! He planned loads of tasks: as many as A_{i} tasks to do on the i_{th} day! Chef's work was brutal, so he only managed to finish B_{i} tasks on the i_{th} day.
The good news is that Chef has a Time Machine! 
The Time Machine has K white buttons and M black buttons. Each button has a positive integer printed on it. Now Chef goes through all N days consequently and presses buttons. Each day Chef can only press one button (either white or black). After using a button once, it becomes inactive.
Pressing a white button with integer x printed on it reduces the number of planned tasks on the day it was pressed by exactly x. Note that this white button can only be pressed if number of planned tasks on the day are greater than or equal to x.
Pressing a black button with integer x printed on it increases the number of completed tasks on the day it was pressed by exactly x. Note that this black button can only be pressed if after pressing it, number of completed tasks don't exceed the number of tasks.
Chef is interested in finding the minimum possible amount of total uncompleted tasks he will still be left with after N days using the Machine in the best way?
Be careful! Time is sensitive! Chef cannot make a day when he completed more tasks then planned, as this may result in a more-work-than-planned paradox, killing all lazy people on the planet!

------ Input ------ 

The first line of input contains a single integer T, denoting the number of test cases. Description of T test cases follows.
The first line of each test case contains three integers — N, K, M — denoting the number of days, white and black buttons appropriately.
The second line contains N space-separated integers A_{1}, A_{2}, … , A_{N}, denoting the number of planned tasks.
The third line contains N space-separated integers B_{1}, B_{2}, … , B_{N}, denoting the number of completed tasks.
The fourth line contains K space-separated integers C_{1}, C_{2}, … , C_{K}, denoting the integers on white buttons.
The fifth and last line contains M space-separated integers D_{1}, D_{2}, … , D_{M}, denoting the integers on black buttons.

------ Output ------ 

In a single line, output an integer — the minimum possible amount of uncompleted tasks.

------ Constraints ------ 

$1 ≤ T ≤ 4$
$1 ≤ N, K, M ≤ 10^{5}$
$1 ≤ B_{i} ≤ A_{i}  ≤ 10^{5}$
$1 ≤ C_{i}, D_{i}  ≤ 10^{5}$

------ Subtasks ------ 

$Subtask N ≤ 10, K, M ≤ 5. Points: 30 $
$Subtask Original constraints. Points: 70 $

----- Sample Input 1 ------ 
1

4 2 2 

5 7 6 1

3 3 1 1

6 3

1 4
----- Sample Output 1 ------ 
3
----- explanation 1 ------ 
Example case 1.
In this example Chef goes through the following steps:
Use black button 1 on the first day.
Use black button 4 on the second day.
Use white button 3 on the third day.
The arrays A and B are now effectively changed to:
5 7 3 1
4 7 1 1
So he will have 3 uncompleted tasks.

Difficulty: MEDIUM_HARD

Solutions:
for _ in range(int(input())):
	(N, K, M) = map(int, input().split())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	buttons = [int(x) for x in input().split()]
	buttons += [int(x) for x in input().split()]
	diff = [A[i] - B[i] for i in range(N)]
	diff.sort(reverse=True)
	buttons.sort(reverse=True)
	accumulated = sum(diff)
	i = 0
	for ele in diff:
		while i < K + M:
			if ele >= buttons[i]:
				accumulated -= buttons[i]
				i += 1
				break
			else:
				i += 1
	print(accumulated)


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	tmp = sorted(c + d)
	res = []
	s = 0
	for i in range(n):
		res.append(a[i] - b[i])
	res.sort()
	(ib, il) = (len(tmp) - 1, len(res) - 1)
	while il >= 0 and ib >= 0:
		while ib >= 0 and tmp[ib] > res[il]:
			ib -= 1
		res[il] -= tmp[ib]
		s += res[il]
		il -= 1
		ib -= 1
	while il >= 0:
		s += res[il]
		il -= 1
	print(s)


test_cases = int(input())
for _ in range(test_cases):
	(numdays, white_buttons, black_buttons) = map(int, input().split())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	K = [int(x) for x in input().split()]
	M = [int(x) for x in input().split()]
	C = [A[i] - B[i] for i in range(numdays)]
	C.sort(reverse=True)
	buttons = sorted(K + M, reverse=True)
	i = 0
	j = 0
	while i < len(C) and j < len(buttons):
		if buttons[j] <= C[i]:
			C[i] -= buttons[j]
			j += 1
			i += 1
		else:
			j += 1
	print(sum(C))


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	K = list(map(int, input().split()))
	M = list(map(int, input().split()))
	K += M
	K.sort(reverse=True)
	C = [a - b for (a, b) in zip(A, B)]
	C.sort(reverse=True)
	inc = sum(C)
	j = 0
	for i in C:
		if i == 0:
			continue
		else:
			while K[j] > i:
				j += 1
			inc -= K[j]
			j += 1
			if j > k + m - 1:
				break
	print(inc)


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	(i, j) = (0, 0)
	new = sorted(c + d, reverse=True)
	adb = [0] * n
	for i in range(n):
		adb[i] = a[i] - b[i]
	j = 0
	minn = 1000000000
	ind = 0
	new_l = len(new)
	adb = sorted(adb, reverse=True)
	for (i, v) in enumerate(adb):
		if v == 0:
			continue
		else:
			while new[j] > v:
				j += 1
			adb[i] -= new[j]
			j += 1
			if j >= new_l:
				break
	print(sum(adb))


t = int(input())
for x in range(0, t):
	(n, k, m) = map(int, input().split())
	a = [int(j) for j in input().split()]
	b = [int(w) for w in input().split()]
	c = [int(e) for e in input().split()]
	d = [int(r) for r in input().split()]
	lis = c + d
	li = []
	for i in range(0, n):
		li.append(a[i] - b[i])
	li.sort(reverse=True)
	lis.sort(reverse=True)
	q = 0
	sum = 0
	z = 0
	y = 0
	un = 0
	while z < m + k and y < n:
		if li[y] >= lis[z]:
			li[y] -= lis[z]
			y += 1
			z += 1
		else:
			z += 1
	r = 0
	while r < n:
		un += li[r]
		r += 1
	print(un)


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, w, b) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	c = list(map(int, stdin.readline().split()))
	for i in range(n):
		a[i] = a[i] - c[i]
	c = list(map(int, (stdin.readline() + ' ' + stdin.readline()).split()))
	a.sort()
	c.sort()
	i = n - 1
	incomplete = 0
	for j in range(w + b - 1, -1, -1):
		if a[i] >= c[j]:
			incomplete += a[i] - c[j]
			i -= 1
	while i >= 0:
		incomplete += a[i]
		i -= 1
	print(incomplete)


for _ in range(int(input())):
	(n, w, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	new = []
	for i in range(len(arr)):
		new.append(abs(arr[i] - arr1[i]))
	res = []
	white = list(map(int, input().split()))
	black = list(map(int, input().split()))
	new.sort(reverse=True)
	for i in white:
		res.append(i)
	for i in black:
		res.append(i)
	res.sort(reverse=True)
	i = 0
	j = 0
	un = 0
	while j < w + b and i < n:
		if new[i] >= res[j]:
			new[i] -= res[j]
			i += 1
			j += 1
		else:
			j += 1
	i = 0
	while i < n:
		un += new[i]
		i += 1
	print(un)


from bisect import *
for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = [i - j for (i, j) in zip(a, b)]
	v = list(map(int, input().split()))
	for i in map(int, input().split()):
		v.append(i)
	v.sort(reverse=True)
	l.sort(reverse=True)
	ans = 0
	pos = 0
	for i in v:
		if i <= l[pos]:
			ans += i
			pos += 1
	print(sum(l) - ans)


def ti():
	return tuple(map(int, input().split()))

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

def si():
	return input().split()

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

def ip():
	return input()
for tastcas in range(int(input())):
	(n, k, m) = li()
	r = k + m
	a = li()
	d = li()
	w = li()
	w += li()
	for i in range(n):
		a[i] -= d[i]
	a.sort()
	w.sort()
	i = n - 1
	j = r - 1
	while i >= 0 and j >= 0:
		while j >= 0 and w[j] > a[i]:
			j -= 1
		if i >= 0:
			a[i] -= w[j]
			i -= 1
			j -= 1
	print(sum(a))


for _ in range(int(input())):
	(n, w, b) = map(int, input().strip().split())
	A = list(map(int, input().strip().split()))
	B = [x - y for (x, y) in zip(A, list(map(int, input().strip().split())))]
	C = list(map(int, input().strip().split()))
	C.extend(list(map(int, input().strip().split())))
	B.sort(reverse=True)
	C.sort(reverse=True)
	cnt = 0
	ans = 0
	total = len(C)
	for day in B:
		while cnt < total and C[cnt] > day:
			cnt += 1
		if cnt < total:
			ans += day - C[cnt]
			cnt += 1
		else:
			ans += day
	print(ans)


def call(A, B, buy, n):
	diff = []
	for i in range(n):
		diff.append(A[i] - B[i])
	diff.sort(reverse=True)
	buy.sort(reverse=True)
	(i, j) = (0, 0)
	while i < n and j < len(buy):
		if diff[i] >= buy[j]:
			diff[i] -= buy[j]
			i += 1
			j += 1
		else:
			j += 1
	return sum(diff)
t = int(input())
while t > 0:
	(n, m, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	D = list(map(int, input().split()))
	print(call(A, B, C + D, n))
	t -= 1


for _ in range(int(input())):
	(N, K, M) = map(int, input().split())
	(A, B, C, D) = (list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())))
	(it, W, S, cnt) = (0, sorted([x - y for (x, y) in zip(A, B)], reverse=True), sorted(C + D, reverse=True), 0)
	for (j, i) in enumerate(W):
		while it < len(S) and S[it] > i:
			it += 1
		if it >= len(S):
			break
		cnt += i - S[it]
		it += 1
	print(cnt + sum(W[j:]))


t = int(input())
for _ in range(t):
	n = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	for i in range(len(a)):
		a[i] = abs(a[i] - b[i])
	c = c + d
	a.sort()
	c.sort()
	a = a[::-1]
	c = c[::-1]
	p1 = 0
	p2 = 0
	counter = 0
	for i in range(n[1] + n[2]):
		if p1 < n[0]:
			if a[p1] >= c[p2]:
				counter += a[p1] - c[p2]
				p1 += 1
				p2 += 1
			else:
				p2 += 1
	if p1 < n[0]:
		for j in range(p1, n[0]):
			counter += a[j]
	print(counter)


import heapq
for i in range(int(input())):
	(n, k, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	D = list(map(int, input().split()))
	L = [0] * n
	for i in range(n):
		L[i] = B[i] - A[i]
	heapq.heapify(L)
	C = C + D
	C.sort()
	ele = abs(heapq.heappop(L))
	sum1 = 0
	for j in range(len(C) - 1, -1, -1):
		if ele == 0:
			break
		elif ele >= C[j]:
			sum1 += ele - C[j]
			ele = abs(heapq.heappop(L))
	print(sum1 + abs(sum(L)) + ele)


for cases in range(int(input())):
	(num_days, num_white, num_black) = map(int, input().split())
	num_comp = list(map(int, input().split()))
	num_incomp = list(map(int, input().split()))
	white = list(map(int, input().split()))
	black = list(map(int, input().split()))
	incomp = []
	for index in range(num_days):
		incomp.append(num_comp[index] - num_incomp[index])
	incomp.sort(reverse=True)
	buttons = white + black
	buttons.sort(reverse=True)
	index2 = 0
	index3 = 0
	while index2 < num_days and index3 < len(buttons):
		if incomp[index2] < buttons[index3]:
			index3 += 1
		else:
			incomp[index2] -= buttons[index3]
			index3 += 1
			index2 += 1
	print(sum(incomp))


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = [a[i] - b[i] for i in range(n)]
	w = list(map(int, input().split()))
	bl = list(map(int, input().split()))
	c = w + bl
	u = 0
	c.sort(reverse=True)
	a.sort(reverse=True)
	i = 0
	for j in c:
		if j <= a[i]:
			u += j
			i += 1
	print(sum(a) - u)


tc = int(input())
for i in range(tc):
	(n, k, m) = list(map(int, input().split()))
	pt = list(map(int, input().split()))
	ct = list(map(int, input().split()))
	wb = list(map(int, input().split()))
	bb = list(map(int, input().split()))
	rm = [x1 - x2 for (x1, x2) in zip(pt, ct)]
	rm.sort(reverse=True)
	full_list = wb[:]
	full_list.extend(bb)
	full_list.sort(reverse=True)
	k1 = 0
	rem = 0
	ind_done = []
	while k1 < len(rm):
		if len(ind_done) == 0:
			j = 0
		else:
			j = ind_done[-1]
		while j < len(full_list) and full_list[j] > rm[k1]:
			j += 1
		if j == len(full_list):
			rem += rm[k1]
			rm.pop(k1)
		else:
			rem += rm[k1] - full_list[j]
			rm.pop(k1)
			full_list.pop(j)
			ind_done.append(j)
	print(rem)


for _ in range(int(input())):
	(n, k, m) = list(map(int, input().split()))
	planned = list(map(int, input().split()))
	completed = list(map(int, input().split()))
	white = list(map(int, input().split()))
	black = list(map(int, input().split()))
	remaining = [planned[i] - completed[i] for i in range(n)]
	rem = sorted(remaining, reverse=True)
	sub = sorted(white + black, reverse=True)
	t = k + m
	j = 0
	for i in range(n):
		while j < t:
			if sub[j] <= rem[i]:
				rem[i] = rem[i] - sub[j]
				j += 1
				break
			j += 1
		if j == t:
			break
	print(sum(rem))


t = int(input())
for i in range(t):
	(n, k, m) = list(map(int, input().split()))
	task_count = list(map(int, input().split()))
	completed_task_count = list(map(int, input().split()))
	white_values = list(map(int, input().split()))
	black_values = list(map(int, input().split()))
	diff_task = [a_i - b_i for (a_i, b_i) in zip(task_count, completed_task_count)]
	diff_task = sorted(diff_task, reverse=True)
	buttons = sorted(white_values + black_values, reverse=True)
	x = 0
	for (idx, element) in enumerate(diff_task):
		if element == 0:
			continue
		else:
			while buttons[x] > element:
				x += 1
			diff_task[idx] -= buttons[x]
			x += 1
			if x >= len(buttons):
				break
	print(sum(diff_task))


T = int(input())
while T > 0:
	(N, K, M) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	D = list(map(int, input().split()))
	C += D
	C.sort(reverse=True)
	Z = [a - b for (a, b) in zip(A, B)]
	Z.sort(reverse=True)
	totalRemaining = sum(Z)
	j = 0
	for i in Z:
		if i == 0:
			continue
		else:
			while C[j] > i:
				j += 1
			totalRemaining -= C[j]
			j += 1
			if j > K + M - 1:
				break
	print(totalRemaining)
	T -= 1


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	c = c + list(map(int, input().split()))
	diff = []
	for i in range(n):
		diff.append(a[i] - b[i])
	diff.sort(reverse=True)
	c.sort(reverse=True)
	ans = 0
	j = 0
	for i in range(n):
		broken = False
		while j < len(c):
			if c[j] <= diff[i]:
				ans += diff[i] - c[j]
				j += 1
				broken = True
				break
			j += 1
		if not broken:
			ans += diff[i]
	print(ans)


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	lc = list(map(int, input().split()))
	cu = list(map(int, input().split()))
	w = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		lc[i] -= cu[i]
	buttons = w + b
	lc.sort()
	buttons.sort()
	j = len(buttons) - 1
	for i in range(n - 1, -1, -1):
		if j >= 0 and i >= 0:
			while buttons[j] > lc[i]:
				j -= 1
				if j < 0:
					break
			if buttons[j] <= lc[i]:
				lc[i] -= buttons[j]
				j -= 1
	total = 0
	for i in range(n):
		total += lc[i]
	print(total)


t = int(input())
for _ in range(t):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	temp = sorted(c + d, reverse=True)
	e = []
	for i in range(n):
		e.append(a[i] - b[i])
	e.sort(reverse=True)
	ans = 0
	j = 0
	for i in e:
		flag = False
		while j < len(temp):
			if temp[j] <= i:
				ans += i - temp[j]
				j += 1
				flag = True
				break
			j += 1
		if not flag:
			ans += i
	print(ans)


for _ in range(int(input())):
	(n, w, b) = map(int, input().split())
	a = list(map(int, input().split()))
	c = list(map(int, input().split()))
	for i in range(n):
		a[i] = a[i] - c[i]
	c = list(map(int, (input() + ' ' + input()).split()))
	a.sort()
	c.sort()
	i = n - 1
	incomplete = 0
	for j in range(w + b - 1, -1, -1):
		if a[i] >= c[j]:
			incomplete += a[i] - c[j]
			i -= 1
	while i >= 0:
		incomplete += a[i]
		i -= 1
	print(incomplete)


t = int(input())
while t > 0:
	(n, k, m) = map(int, input().split())
	planned = list(map(int, input().split()))
	complete = list(map(int, input().split()))
	white = list(map(int, input().split()))
	black = list(map(int, input().split()))
	l = []
	for i in range(0, len(planned)):
		l.append(planned[i] - complete[i])
	lis = []
	lis = white + black
	lis.sort(reverse=True)
	l.sort(reverse=True)
	n1 = 0
	mk1 = 0
	while n1 <= len(l) and mk1 < len(lis):
		if l[n1] < lis[mk1]:
			mk1 += 1
		else:
			l[n1] -= lis[mk1]
			mk1 += 1
			n1 += 1
	left = 0
	for i in range(0, len(l)):
		left += l[i]
	print(left)
	t -= 1


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	a = [a[i] - b[i] for i in range(n)]
	e = c + d
	e.sort(reverse=True)
	a.sort(reverse=True)
	(x, y) = (0, 0)
	while y < len(e):
		if e[y] <= a[x]:
			a[x] -= e[y]
			x += 1
			e.pop(y)
		else:
			y += 1
	print(sum(a))


T = int(input())
output = []
for _ in range(T):
	(N, K, M) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = [(x, 'white') for x in list(map(int, input().split()))]
	D = [(x, 'black') for x in list(map(int, input().split()))]
	buttons = C + D
	buttons.sort(key=lambda x: x[0])
	diffs = [a - b for (a, b) in zip(A, B)]
	diffs.sort()
	uncompleted = 0
	while len(diffs) > 0:
		d = diffs.pop()
		while len(buttons) > 0 and d < buttons[-1][0]:
			buttons.pop()
		if len(buttons) > 0:
			b = buttons.pop()
			d -= b[0]
		uncompleted += d
	output.append(uncompleted)
for o in output:
	print(o)


test = int(input())
for _ in range(test):
	(n, k, m) = map(int, input().split())
	task_arr = [int(i) for i in input().split()]
	done_arr = [int(i) for i in input().split()]
	w_arr = [int(i) for i in input().split()]
	b_arr = [int(i) for i in input().split()]
	diff_arr = [task_arr[i] - done_arr[i] for i in range(n)]
	diff_arr = sorted(diff_arr, reverse=True)
	w_arr = sorted(w_arr, reverse=True)
	b_arr = sorted(b_arr, reverse=True)
	(w, b) = (0, 0)
	for i in range(n):
		while w < k and w_arr[w] > diff_arr[i]:
			w += 1
		while b < m and b_arr[b] > diff_arr[i]:
			b += 1
		if w == k and b == m:
			break
		if w == k:
			diff_arr[i] -= b_arr[b]
			b += 1
		elif b == m:
			diff_arr[i] -= w_arr[w]
			w += 1
		elif w_arr[w] > b_arr[b]:
			diff_arr[i] -= w_arr[w]
			w += 1
		else:
			diff_arr[i] -= b_arr[b]
			b += 1
	minsum = 0
	for i in range(n):
		minsum += diff_arr[i]
	print(minsum)


t = int(input())
while t:
	n_k_m = [int(i) for i in input().split()]
	n = n_k_m[0]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	k = [int(i) for i in input().split()]
	m = [int(i) for i in input().split()]
	inactive_dict = {}
	res = 0
	diff = [abs(a[i] - b[i]) for i in range(n)]
	rev_diff = sorted(diff, reverse=True)
	rev = sorted(k + m, reverse=True)
	aa = sum(diff)
	i = 0
	j = 0
	while i < len(rev) and j < len(rev_diff):
		if rev[i] <= rev_diff[j]:
			res += rev[i]
			i += 1
			j += 1
		else:
			i += 1
	print(aa - res)
	t -= 1


for q in range(int(input())):
	(n, wn, bn) = [int(e) for e in input().split()]
	a1 = [int(e) for e in input().split()]
	a2 = [int(e) for e in input().split()]
	a = []
	for i in range(n):
		a.append(abs(a1[i] - a2[i]))
	a.sort(reverse=True)
	w = [int(e) for e in input().split()]
	b = [int(e) for e in input().split()]
	w.extend(b)
	w.sort(reverse=True)
	j = 0
	i = 0
	l = len(w)
	while i < n:
		if j >= l:
			break
		elif a[i] >= w[j]:
			a[i] -= w[j]
			i += 1
		j += 1
	print(sum(a))


import string
from functools import lru_cache
import atexit, io
import sys
from math import log2
import math
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right, insort
from math import gcd
from math import sqrt
from collections import Counter, defaultdict
from heapq import heappush, heappop, heapify
import heapq

class FenwickTree:

	def __init__(self, n):
		self.farr = [0] * (n + 1)

	def prefixSum(self, idx):
		s = 0
		while idx > 0:
			s += self.farr[idx]
			idx -= idx & -idx
		return s

	def update(self, idx, val):
		while idx < len(self.farr):
			self.farr[idx] += val
			idx += idx & -idx

	def find(self, k):
		curr = 0
		ans = 0
		prevSum = 0
		for i in range(log2(n), -1, -1):
			if self.farr[curr + (i << i)] + prevSum < k:
				curr += 1 << i
				prevSum += self.farr[curr]
		return curr + 1

class Trie(object):

	def __init__(self):
		self.trie = {}

	def insert(self, word):
		t = self.trie
		for c in word:
			if c not in t:
				t[c] = {}
			t = t[c]
		t['-'] = True

	def search(self, word):
		t = self.trie
		for c in word:
			if c not in t:
				return False
			t = t[c]
		return '-' in t

	def startsWith(self, prefix):
		t = self.trie
		for c in prefix:
			if c not in t:
				return False
			t = t[c]
		return True

	def query(self, word):
		ans = 0
		t = self.trie
		for i in word:
			if i not in t:
				break
			ans += 1
			t = t[i]
		return ans

class FenvTree:

	def __init__(self, arr):
		arr.insert(0, 0)
		self.farr = [0]
		prefix = [0]
		for i in arr[1:]:
			prefix.append(prefix[-1] + i)
		for i in range(1, len(arr)):
			idash = i - (i & -i)
			self.farr.append(prefix[i] - prefix[idash])

	def query(self, l, r):
		return self.prefixSum(r) - self.prefixSum(l - 1)

	def prefixSum(self, idx):
		s = 0
		while idx > 0:
			s += self.farr[idx]
			idx -= idx & -idx
		return s

	def update(self, idx, val):
		while idx < len(self.farr):
			self.farr[idx] += val
			idx += idx & -idx

class DSU:

	def __init__(self, n):
		self.parent = []
		self.size = []
		for i in range(n + 1):
			self.parent.append(i)
			self.size.append(1)

	def union(self, u, v):
		pu = self.findPar(u)
		pv = self.findPar(v)
		if pu == pv:
			return
		if self.size[pu] < self.size[pv]:
			self.parent[pu] = pv
			self.size[pv] += self.size[pu]
		else:
			self.parent[pv] = pu
			self.size[pu] += self.size[pv]

	def unionByRank(self, u, v):
		pu = self.findPar(u)
		pv = self.findPar(v)
		if pu == pv:
			return
		if self.rank[pu] < self.rank[pv]:
			self.parent[pu] = pv
		elif self.rank[pv] < self.rank[pu]:
			self.parent[pv] = pu
		else:
			self.parent[pu] = pv
			self.rank[pv] += 1

	def findPar(self, node):
		if self.parent[node] == node:
			return node
		self.parent[node] = self.findPar(self.parent[node])
		return self.parent[node]

class info:

	def __init__(self, _open=0, _close=0, _full=0):
		self.open = _open
		self.close = _close
		self.full = _full

class SGTree:

	def __init__(self, n):
		self.seg = [0 for _ in range(4 * n)]

	def build(self, ind, low, high, arr):
		if low == high:
			self.seg[ind] = arr[low]
			return
		mid = (low + high) // 2
		self.build(2 * ind + 1, low, mid, arr)
		self.build(2 * ind + 2, mid + 1, high, arr)
		self.seg[ind] = min(self.seg[2 * ind + 1], self.seg[2 * ind + 2])

	def query(self, ind, low, high, l, r):
		if r < low or l > high:
			return sys.maxsize
		if low <= l and r >= high:
			return self.seg[ind]
		mid = low + high >> 1
		left = self.query(2 * ind + 1, 0, mid, l, r)
		right = self.query(2 * ind + 2, mid + 1, high, l, r)
		return min(left, right)

	def update(self, ind, low, high, i, val):
		if low == high:
			self.seg = val
			return
		mid = low + high >> 1
		if i <= mid:
			self.update(2 * ind + 1, low, mid, i, val)
		else:
			self.update(2 * ind + 1, mid + 1, high, i, val)
		self.seg[ind] = min(self.seg[2 * ind + 1], self.seg[2 * ind + 2])

def isPalindrome(s):
	i = 0
	j = len(s) - 1
	while i < j:
		if s[i] != s[j]:
			return False
		i += 1
		j -= 1
	return True

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

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

def getStrs():
	return sys.stdin.readline().strip()

def StrList():
	list(sys.stdin.readline().strip())

def FloatList():
	lis = input().split()
	lis = list(map(float, lis))
	return lis

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

def findPrimePair(n):
	isPrime = [0] * (n + 1)
	SieveOfEratosthenes(n, isPrime)
	for i in range(0, n):
		if isPrime[i] and isPrime[n - i]:
			print(i, n - i)
			return

def query(ind, low, high, l, r, seg):
	if r < low or l > high:
		return info()
	if low <= l and r >= high:
		return self.seg[ind]
	mid = low + high >> 1
	left = self.query(2 * ind + 1, 0, mid, l, r, seg)
	right = self.query(2 * ind + 2, mid + 1, high, l, r, seg)
	return merge(left, right)

def merge(left, right):
	ans = info()
	ans.full = left.full + right.full + min(left.open, right.close)
	ans.open = left.open + right.open + min(left.open, right.close)
	ans.close = left.close + right.close + min(left.open, right.close)
	return ans

def build(ind, low, high, s, seg):
	if low == high:
		seg[ind] = info(s[low] == '(', s[low] == ')', 0)
		return
	mid = (low + high) // 2
	build(2 * ind + 1, low, mid, s, seg)
	build(2 * ind + 2, mid + 1, high, s, seg)
	seg[ind] = merge(seg[2 * ind + 1], seg[2 * ind + 2])

def countN(lis):
	ans = 0
	cnt = 0
	for i in range(len(lis) - 1, -1, -1):
		if lis[i] == 0:
			cnt += 1
		else:
			ans += cnt
	return ans

class Pair:

	def __init__(self, x, y, gcd):
		self.x = x
		self.y = y
		self.gcd = gcd

def Euclidean(a, b):
	if b == 0:
		return Pair(1, 0, a)
	dash = Euclidean(b, a % b)
	return Pair(dash.y, dash.x - a // b * dash.y, dash.gcd)

def chineseRemainder(a1, n1, a2, n2):
	p = Euclidean(n1, n2)
	x = p.x
	gcd = p.gcd
	if (a1 - a2) % gcd:
		return -1
	k = (a1 - a2) // gcd
	a = a1 - n1 * (k * x % n2 // gcd)
	lcm = n1 * n2 // gcd
	if a < 0:
		a += lcm
	return a

def ncr(n, k, md):
	mod = 998244353
	tab = [[0 for _ in range(k + 1)] for i in range(n + 1)]
	for i in range(1, len(tab)):
		tab[i][0] = 1
	for i in range(1, len(tab)):
		for j in range(1, min(i + 1, len(tab[0]))):
			if i == 1 and j == 1:
				tab[i][j] = 1
			else:
				tab[i][j] = (tab[i - 1][j] + tab[i - 1][j - 1]) % mod
	return tab

def repeat(i, j, arr):
	if i > j:
		return
	cnt1 = i
	cnt2 = j
	while cnt1 < cnt2:
		(arr[cnt1], arr[cnt2]) = (arr[cnt2], arr[cnt1])
		cnt1 += 1
		cnt2 -= 1
	if i - 1 >= 0:
		ele = arr[i - 1]
		if ele > 0:
			s = int(sqrt(ele - 1)) + 1
			first = s * s - ele
			repeat(first, i - 1, arr)
	return
spf = []

def makeSeive(n):
	for i in range(n + 1):
		spf.append(i)

def seive(n):
	s = int(sqrt(n + 1))
	for i in range(2, s + 1):
		if spf[i] == i:
			for j in range(i * i, n + 1, i):
				if spf[j] == j:
					spf[j] = i

def getFactorization(x):
	ret = set()
	while x != 1:
		ret.add(spf[x])
		x = x // spf[x]
	return ret

def getLPS(s):
	st = '@#' + '#'.join(s) + '#&'
	c = 0
	r = 0
	lps = [0] * len(st)
	for i in range(1, len(st) - 1):
		mirror = c - (i - c)
		if i < r and mirror >= 0:
			lps[i] = min(lps[mirror], r - i)
		while st[i + lps[i] + 1] == st[i - lps[i] - 1]:
			lps[i] += 1
		if i + lps[i] > r:
			r = i + lps[i]
			c = i
	return max(lps)
fact = [1 for _ in range(100002)]
mod = 10 ** 9 + 7

def getFact(n):
	for i in range(1, n + 1):
		fact[i] = fact[i - 1] * i % mod

def getInv(word):
	num = math.factorial(len(word))
	for v in Counter(word).values():
		num = num * pow(math.factorial(v), mod - 2, mod) % mod
	return int(num) % (10 ** 9 + 7)

def subarrayXor(arr, n, m):
	HashTable = defaultdict(bool)
	HashTable[0] = 1
	count = 0
	curSum = 0
	for i in arr:
		curSum ^= i
		if HashTable[curSum ^ m]:
			count += HashTable[curSum ^ m]
		HashTable[curSum] += 1
	return count

def get2dPrefixSum(matrix, mid=0):
	n = len(matrix)
	m = len(matrix[0])
	prefix = [[0 for _ in range(m + 1)] for i in range(n + 1)]
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			prefix[i][j] = prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1] + matrix[i - 1][j - 1]
	return prefix

def get2dPrefixSumCnt(matrix, mid=0):
	n = len(matrix)
	m = len(matrix[0])
	prefix = [[0 for _ in range(m + 1)] for i in range(n + 1)]
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			prefix[i][j] = prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1] + matrix[i - 1][j - 1]
	return prefix

def getSumRange(r1, c1, r2, c2, prefix):
	cnt = prefix[r2][c2] - prefix[r2][c1 - 1] - prefix[r1 - 1][c2] + prefix[r1 - 1][c1 - 1]
	return cnt

def getPrefix(arr):
	prefix = [0]
	for i in arr:
		prefix.append(prefix[-1] + i)
	return prefix

def getInv(arr):
	cnt = 0
	ans = []
	for i in arr:
		ind = bisect_right(ans, i)
		cnt += len(ans) - ind
		insort(ans, i)
	return cnt
M = 10 ** 5

def getFactors(x):
	temp = []
	k = 1
	while k * k <= x:
		if x % k == 0:
			temp.append(k)
			if k * k != x:
				temp.append(x // k)
		k += 1
	return temp

def grayCode(n):
	if not n:
		return [0]
	res = [0, 1]
	for i in range(2, n + 1):
		for j in range(len(res) - 1, -1, -1):
			res.append(res[j] | 1 << i - 1)
	return res

def threeSum(nums, target):
	ans = -1
	d = dict()
	for (i, j) in enumerate(nums):
		d[j] = i + 1
	nums.sort()
	for i in range(len(nums) - 2):
		low = i + 1
		high = len(nums) - 1
		while low < high:
			s = nums[i] + nums[low] + nums[high]
			if s == target:
				print(d[nums[low]], d[nums[high]], d[nums[i]])
				return
				low += 1
				high -= 1
			elif s < 0:
				low = low + 1
			else:
				high -= 1
	print('IMPOSSIBLE')
	return

def FUCKCF():
	(n, k, m) = getInts()
	a = IntList()
	b = IntList()
	c = IntList()
	c.extend(IntList())
	c.sort(reverse=1)
	diff = [i - j for (i, j) in list(zip(a, b))]
	diff.sort(reverse=1)
	s = sum(diff)
	i = 0
	j = 0
	while i < n and j < k + m:
		if diff[i] >= c[j]:
			i += 1
			j += 1
			s -= c[j - 1]
		else:
			j += 1
	print(s)
t = 1
t = int(input())
for i in range(t):
	FUCKCF()


t = int(input())
for i in range(t):
	(n, k, m) = list(map(int, input().split()))
	plan = list(map(int, input().split()))
	comp = list(map(int, input().split()))
	white = list(map(int, input().split()))
	black = list(map(int, input().split()))
	rem = []
	p = 0
	machine = []
	count_rem = 0
	count_machine = 0
	for j in range(n):
		rem.append(plan[j] - comp[j])
	count_rem += sum(rem)
	rem.sort(reverse=True)
	machine.extend(white)
	machine.extend(black)
	machine.sort(reverse=True)
	count_machine += sum(machine)
	if machine[0] <= rem[-1]:
		count_rem -= count_machine
	elif machine[-1] > rem[0]:
		pass
	else:
		for (j, val) in enumerate(machine):
			while rem != []:
				if val <= rem[p]:
					count_rem -= val
					rem.pop(p)
					break
				else:
					break
	print(count_rem)


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	ls = list(map(int, input().split()))
	temp = list(map(int, input().split()))
	ls = [ls[i] - temp[i] for i in range(n)]
	b = list(map(int, input().split()))
	b1 = list(map(int, input().split()))
	b = b + b1
	ls.sort(reverse=True)
	b.sort(reverse=True)
	j = 0
	for i in range(n):
		if j < k + m:
			while True:
				if ls[i] >= b[j]:
					ls[i] -= b[j]
					j += 1
					break
				j += 1
	print(sum(ls))


T = int(input())
for i in range(T):
	NKM = str(input()).split(' ')
	N = int(NKM[0])
	K = int(NKM[1])
	M = int(NKM[2])
	A = str(input()).split(' ')
	B = str(input()).split(' ')
	C = str(input()).split(' ')
	D = str(input()).split(' ')
	mix = []
	for j in range(N):
		mix.append((int(A[j]), int(B[j])))
	for j in range(K):
		C[j] = int(C[j])
	for j in range(M):
		D[j] = int(D[j])
	mix.sort(key=lambda x: x[0] - x[1], reverse=True)
	C.sort(reverse=True)
	D.sort(reverse=True)
	left = 0
	ccur = 0
	dcur = 0
	for j in range(N):
		if mix[j][0] - mix[j][1]:
			flag = 1
			while flag and (ccur < K or dcur < M):
				if ccur < K:
					if dcur < M:
						if C[ccur] > D[dcur]:
							if C[ccur] <= mix[j][0] - mix[j][1]:
								left = left + (mix[j][0] - mix[j][1]) - C[ccur]
								ccur = ccur + 1
								flag = 0
							else:
								ccur = ccur + 1
						elif D[dcur] <= mix[j][0] - mix[j][1]:
							left = left + (mix[j][0] - mix[j][1]) - D[dcur]
							dcur = dcur + 1
							flag = 0
						else:
							dcur = dcur + 1
					elif C[ccur] <= mix[j][0] - mix[j][1]:
						left = left + (mix[j][0] - mix[j][1]) - C[ccur]
						ccur = ccur + 1
						flag = 0
					else:
						ccur = ccur + 1
				elif dcur < M:
					if D[dcur] <= mix[j][0] - mix[j][1]:
						left = left + (mix[j][0] - mix[j][1]) - D[dcur]
						dcur = dcur + 1
						flag = 0
					else:
						dcur = dcur + 1
			if flag:
				left = left + (mix[j][0] - mix[j][1])
	print(left)


def minTasks(diff, buttons):
	(i, j) = (0, 0)
	incompleteTasks = 0
	while i < len(diff) and j < len(buttons):
		if diff[i] >= buttons[j]:
			incompleteTasks += diff[i] - buttons[j]
			i += 1
			j += 1
		else:
			j += 1
	while i < len(diff):
		incompleteTasks += diff[i]
		i += 1
	return incompleteTasks
t = int(input())
while t > 0:
	(n, k, m) = map(int, input().strip().split())
	planned = list(map(int, input().strip().split()))
	completed = list(map(int, input().strip().split()))
	white = list(map(int, input().strip().split()))
	black = list(map(int, input().strip().split()))
	buttons = white + black
	buttons.sort(reverse=True)
	diff = []
	for i in range(n):
		diff.append(planned[i] - completed[i])
	diff.sort(reverse=True)
	print(minTasks(diff, buttons))
	t -= 1


for x in range(int(input())):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	wt = list(map(int, input().split()))
	bk = list(map(int, input().split()))
	c = [a[i] - b[i] for i in range(n)]
	c.sort()
	wt.sort()
	bk.sort()
	ans = 0
	while c:
		top = c[-1]
		c.pop()
		while wt:
			if wt and wt[-1] > top:
				wt.pop()
			else:
				break
		while bk:
			if bk and bk[-1] > top:
				bk.pop()
			else:
				break
		if not wt and (not bk):
			ans += top
		elif not wt:
			ans += top - bk[-1]
			bk.pop()
		elif not bk:
			ans += top - wt[-1]
			wt.pop()
		elif wt[-1] > bk[-1]:
			ans += top - wt[-1]
			wt.pop()
		else:
			ans += top - bk[-1]
			bk.pop()
	print(ans)


t = int(input())
for i in range(t):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	z = sorted(c + d, reverse=True)
	s = [0] * n
	for j in range(n):
		s[j] = a[j] - b[j]
	x = 0
	w = len(z)
	s = sorted(s, reverse=True)
	for (j, v) in enumerate(s):
		if v == 0:
			continue
		else:
			while z[x] > v:
				x += 1
			s[j] -= z[x]
			x += 1
			if x >= w:
				break
	print(sum(s))


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	val = sorted([arr1[i] - arr2[i] for i in range(n)])[::-1]
	w = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = sorted(w + b)[::-1]
	i = j = 0
	while j < k + m and i < n:
		if val[i] >= f[j]:
			val[i] -= f[j]
			j += 1
			i += 1
		else:
			j += 1
	print(sum(val))


from bisect import bisect_left
t = int(input())
for _ in range(t):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	temp = sorted(c + d)
	e = []
	for i in range(n):
		e.append(abs(a[i] - b[i]))
	e.sort(reverse=True)
	ans = 0
	for i in e:
		if i == 0:
			continue
		j = bisect_left(temp, i + 1)
		if j - 1 >= 0 and j - 1 < len(temp):
			ans += i - temp[j - 1]
			temp.pop(j - 1)
		else:
			ans += i
	print(ans)


for _ in range(int(input())):
	(days, white, black) = map(int, input().split())
	planned = list(map(int, input().split()))
	completed = list(map(int, input().split()))
	whiteblack = list(map(int, input().split())) + list(map(int, input().split()))
	whiteblack.sort(reverse=True)
	diff = [planned[i] - completed[i] for i in range(days) if planned[i] - completed[i] > 0]
	diff.sort(reverse=True)
	t = 0
	ans = sum(diff)
	for i in diff:
		for j in range(t, white + black):
			if whiteblack[j] <= i:
				ans -= whiteblack[j]
				t = j + 1
				break
	print(ans)


t = int(input())
while t:
	(n, k, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	diff = []
	for (a, b) in zip(arr, brr):
		diff.append(abs(a - b))
	wbrr = list(map(int, input().split()))
	bbrr = list(map(int, input().split()))
	btn = wbrr + bbrr
	btn.sort(reverse=True)
	diff.sort(reverse=True)
	i = 0
	top = 0
	while top < k + m and i < n:
		if btn[top] <= diff[i]:
			diff[i] -= btn[top]
			i += 1
		top += 1
	print(sum(diff))
	t -= 1


for _ in range(int(input())):
	(num_days, num_white_buttons, num_black_buttons) = map(int, input().split())
	planned_tasks = list(map(int, input().split()))
	completed_tasks = list(map(int, input().split()))
	white_buttons = list(map(int, input().split()))
	black_buttons = list(map(int, input().split()))
	remaining_tasks = [i_planned_tasks - i_completed_tasks for (i_planned_tasks, i_completed_tasks) in zip(planned_tasks, completed_tasks)]
	button_powers = white_buttons + black_buttons
	remaining_tasks.sort(reverse=True)
	button_powers.sort(reverse=True)
	remaining_tasks_index = 0
	button_powers_index = 0
	while remaining_tasks_index < len(remaining_tasks) and button_powers_index < len(button_powers):
		if remaining_tasks[remaining_tasks_index] >= button_powers[button_powers_index]:
			remaining_tasks[remaining_tasks_index] -= button_powers[button_powers_index]
			remaining_tasks_index += 1
		button_powers_index += 1
	print(sum(remaining_tasks))


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split())) + list(map(int, input().split()))
	c.sort(reverse=True)
	diff = [a[i] - b[i] for i in range(n) if a[i] - b[i] > 0]
	diff.sort(reverse=True)
	t = 0
	l = len(c)
	ans = sum(diff)
	for i in diff:
		for j in range(t, l):
			if c[j] <= i:
				ans -= c[j]
				t = j + 1
				break
	print(ans)


t = int(input())
while t:
	(N, K, M) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	k = list(map(int, input().split()))
	m = list(map(int, input().split()))
	d = []
	for i in range(N):
		d.append(A[i] - B[i])
	d.sort(reverse=True)
	k.extend(m)
	k.sort(reverse=True)
	j = 0
	sum = 0
	for i in range(len(k)):
		if j < len(d):
			if k[i] <= d[j]:
				sum += d[j] - k[i]
				i += 1
				j += 1
			else:
				i += 1
		else:
			break
	while j < len(d):
		sum += d[j]
		j += 1
	print(sum)
	t -= 1


t = int(input())

def get_params(inp):
	inp = inp.split()
	inp = [int(i) for i in inp]
	return inp
for k in range(t):
	params = str(input())
	(n, k, m) = get_params(params)
	planned = str(input())
	planned = get_params(planned)
	done = str(input())
	done = get_params(done)
	white = get_params(str(input()))
	black = get_params(str(input()))
	total = white + black
	total = sorted(total)[::-1]
	remain = [planned[i] - done[i] for i in range(len(planned))]
	remain = sorted(remain)[::-1]
	(p1, p2) = (0, 0)
	ans = sum(remain)
	while True:
		r = remain[p1]
		s = total[p2]
		if s > r:
			p2 = p2 + 1
		else:
			ans = ans - s
			p1 = p1 + 1
			p2 = p2 + 1
		if p2 == len(total) or p1 == len(remain):
			break
	print(ans)


for i in range(int(input())):
	(n, w, b) = map(int, input().split())
	uct = list(map(int, input().split()))
	ct = list(map(int, input().split()))
	wb = list(map(int, input().split()))
	bb = list(map(int, input().split()))
	diff = list()
	for i in range(n):
		diff.append(abs(uct[i] - ct[i]))
	b = wb + bb
	diff.sort(reverse=True)
	b.sort(reverse=True)
	(x, y) = (0, 0)
	while y < len(b):
		if b[y] <= diff[x]:
			diff[x] -= b[y]
			x += 1
			b.pop(y)
		else:
			y += 1
	print(sum(diff))


for z in range(int(input())):
	(n, k, m) = map(int, input().split())
	pt = list(map(int, input().split()))
	ct = list(map(int, input().split()))
	wb = list(map(int, input().split()))
	bb = list(map(int, input().split()))
	wb.extend(bb)
	c = 0
	wb.sort(reverse=True)
	a = []
	for i in range(n):
		a.append(pt[i] - ct[i])
	a.sort(reverse=True)
	x = 0
	for i in range(n):
		if a[i] == 0:
			continue
		else:
			for j in range(x, len(wb)):
				if wb[j] <= a[i]:
					a[i] = a[i] - wb[j]
					wb[j] = 0
					x = j + 1
					break
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	c.extend(d)
	diff = [0 for i in range(n)]
	for i in range(n):
		diff[i] = a[i] - b[i]
	diff.sort(reverse=True)
	c.sort(reverse=True)
	bid = 0
	for j in range(n):
		while c[bid] > diff[j]:
			bid += 1
			if bid >= k + m:
				break
		if bid >= k + m:
			break
		else:
			diff[j] -= c[bid]
			bid += 1
			if bid >= k + m:
				break
	print(sum(diff))


import heapq
for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	tasks = list(map(int, input().split()))
	completed = list(map(int, input().split()))
	white = list(map(int, input().split()))
	black = list(map(int, input().split()))
	diff = sorted([tasks[i] - completed[i] for i in range(n)], reverse=True)
	new = white + black
	maxH = [-new[i] for i in range(len(new))]
	heapq.heapify(maxH)
	for (i, d) in enumerate(diff):
		while maxH:
			button = -heapq.heappop(maxH)
			if d >= button:
				diff[i] -= button
				break
	print(sum(diff))


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	B = list(map(int, input().split()))
	D = list(map(int, input().split()))
	L = list(map(int, input().split()))
	N = list(map(int, input().split()))
	L += N
	L.sort(reverse=True)
	D = [a - b for (a, b) in zip(B, D)]
	D.sort(reverse=True)
	incr = sum(D)
	j = 0
	for i in D:
		if i == 0:
			continue
		else:
			while L[j] > i:
				j += 1
			incr -= L[j]
			j += 1
			if j > k + m - 1:
				break
	print(incr)


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	for i in range(n):
		arr1[i] = arr1[i] - arr2[i]
	arr2 = list(map(int, (input() + ' ' + input()).split()))
	arr1.sort()
	arr2.sort()
	i = n - 1
	inc = 0
	for j in range(k + m - 1, -1, -1):
		if arr1[i] >= arr2[j]:
			inc += arr1[i] - arr2[j]
			i -= 1
	while i >= 0:
		inc += arr1[i]
		i -= 1
	print(inc)


T = int(input())
for z in range(T):
	(N, K, M) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	lst = [lst1[i] - lst2[i] for i in range(N) if lst1[i] - lst2[i] > 0]
	lst.sort(reverse=True)
	button = list(map(int, input().split()))
	button += list(map(int, input().split()))
	button.sort(reverse=True)
	res = sum(lst)
	i = 0
	for elem in lst:
		while i < K + M:
			if elem >= button[i]:
				res -= button[i]
				i += 1
				break
			else:
				i += 1
	print(res)