Kiyora has $n$ whiteboards numbered from $1$ to $n$. Initially, the $i$-th whiteboard has the integer $a_i$ written on it.

Koxia performs $m$ operations. The $j$-th operation is to choose one of the whiteboards and change the integer written on it to $b_j$.

Find the maximum possible sum of integers written on the whiteboards after performing all $m$ operations.


-----Input-----

Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 1000$) — the number of test cases. The description of test cases follows.

The first line of each test case contains two integers $n$ and $m$ ($1 \le n,m \le 100$).

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$).

The third line of each test case contains $m$ integers $b_1, b_2, \ldots, b_m$ ($1 \le b_i \le 10^9$).


-----Output-----

For each test case, output a single integer — the maximum possible sum of integers written on whiteboards after performing all $m$ operations.


-----Examples-----

Input
4
3 2
1 2 3
4 5
2 3
1 2
3 4 5
1 1
100
1
5 3
1 1 1 1 1
1000000000 1000000000 1000000000
Output
12
9
1
3000000002


-----Note-----

In the first test case, Koxia can perform the operations as follows:

Choose the $1$-st whiteboard and rewrite the integer written on it to $b_1=4$.

Choose the $2$-nd whiteboard and rewrite to $b_2=5$.

After performing all operations, the numbers on the three whiteboards are $4$, $5$ and $3$ respectively, and their sum is $12$. It can be proven that this is the maximum possible sum achievable.

In the second test case, Koxia can perform the operations as follows:

Choose the $2$-nd whiteboard and rewrite to $b_1=3$.

Choose the $1$-st whiteboard and rewrite to $b_2=4$.

Choose the $2$-nd whiteboard and rewrite to $b_3=5$.

The sum is $4 + 5 = 9$. It can be proven that this is the maximum possible sum achievable.

Difficulty: EASY

Solutions:
inp = (*open(0),)
out = []
for (a, b) in zip(inp[2::3], inp[3::3]):
	a = list(map(int, a.split()))
	b = list(map(int, b.split()))
	out.append(str(sum(sorted(a + b[:-1], reverse=True)[:len(a) - 1]) + b[-1]))
print('\n'.join(out))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k1 = b[-1]
	b.remove(k1)
	l = a + b
	l.sort()
	l = l[::-1]
	l.insert(0, k1)
	print(sum(l[:n]))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if n == 1:
		print(b[-1])
	else:
		print(sum((sorted(a + b[:-1]) + [b[-1]])[-n:]))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	b = s2.pop()
	l2 = s1 + s2
	l2.sort()
	l3 = l2[m:m + n - 1]
	print(sum(l3) + b)


def run():
	_ = input()
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	n = len(a)
	if n == 1:
		print(b[-1])
		return
	arr = a + b[:-1]
	arr.sort()
	print(sum(arr[-(n - 1):]) + b[-1])
tests_nr = int(input())
for _ in range(tests_nr):
	run()


I = lambda : [*map(int, input().split())]
for _ in ' ' * I()[0]:
	(n, m) = I()
	a = I()
	b = I()
	if n == 1:
		print(b[-1])
		continue
	print(sum(sorted(a + b[:-1])[-n + 1:]) + b[-1])


import sys, heapq
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	heapq.heapify(a)
	for i in range(m):
		heapq.heappop(a)
		heapq.heappush(a, b[i])
	print(sum(a))


def max_sum(n, m, a, b):
	d = b
	b = b[:-1]
	c = a + b
	c = sorted(c, reverse=True)
	c = c[:n - 1]
	ans = sum(c) + d[-1]
	return ans
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(max_sum(n, m, a, b))


test_cases = int(input())
for i in range(test_cases):
	(n, m) = map(int, input().split())
	a_list = input().split()
	b_list = input().split()
	ai_list = [int(item) for item in a_list]
	bj_list = [int(item) for item in b_list]
	c_list = ai_list + bj_list
	c_list.sort()
	c_list.reverse()
	if bj_list[m - 1] not in c_list[0:n]:
		c_list[n - 1] = bj_list[m - 1]
	print(sum(c_list[0:n]))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = [b[-1]]
	b.pop()
	a += b
	a.sort(reverse=True)
	res.extend(a)
	print(sum(res[:n]))


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = sorted(map(int, input().split()))
	b = list(map(int, input().split()))
	c = sorted(a + b[:-1])
	if len(a) == 1:
		print(b[-1])
	else:
		print(b[-1] + sum(c[-n + 1:]))


t = int(input())
while t > 0:
	t = t - 1
	a = []
	b = []
	c = []
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = b[m - 1]
	b.pop()
	c = a + b
	c.sort(reverse=True)
	ans = f
	for i in range(n - 1):
		ans += c[i]
	print(ans)


for _ in ' ' * int(input()):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(sorted(a + b[:-1], reverse=True)[:n - 1]) + b[-1]
	print(s)


import sys
input = sys.stdin.readline
case = int(input())
for c in range(case):
	(n, m) = map(int, input().split())
	ln = list(map(int, input().split()))
	lm = list(map(int, input().split()))
	a = ln + lm
	b = [a[-1]]
	b = b + sorted(a[:-1], reverse=True)
	ans = 0
	for i in range(n):
		ans += b[i]
	print(ans)


import heapq

def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	heapq.heapify(a)
	for b in map(int, input().split()):
		heapq.heapreplace(a, b)
	print(sum(a))
for _ in range(int(input())):
	solve()


from heapq import heapify, heapreplace
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	heapify(a)
	b = map(int, input().split())
	for x in b:
		heapreplace(a, x)
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	last_b = b[m - 1]
	c = a + b[:m - 1]
	c.sort()
	print(last_b + sum(c[m:]))


t = int(input(''))
for _ in range(t):
	(n, m) = [int(x) for x in input('').split(' ')]
	A = [int(x) for x in input('').split(' ')]
	B = [int(x) for x in input('').split(' ')]
	C = sorted(A + B[:-1])
	x = B[-1]
	if n == 1:
		print(x)
	else:
		print(x + sum(C[-n + 1:]))


from heapq import heapify, heappop, heappush
for tcase in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	heapify(a)
	for x in b:
		y = heappop(a)
		heappush(a, x)
	print(sum(a))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	c += b[-1]
	b.pop(-1)
	l = a + b
	l.sort(reverse=True)
	for j in range(n - 1):
		c += l[j]
	print(c)


from heapq import heappush, heappop, heapify
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	heapify(l)
	for i in range(m):
		tmp = heappop(l)
		heappush(l, l1[i])
	print(sum(l))


from heapq import *
R = lambda : map(int, input().split())
(t,) = R()
while t:
	t -= 1
	R()
	(*a,) = R()
	heapify(a)
	for x in R():
		heapreplace(a, x)
	print(sum(a))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(num) for num in input().split()]
	a += [int(num) for num in input().split()]
	sorted_lst = sorted(a[:-1]) + [a[-1]]
	sorted_lst.reverse()
	ans = 0
	for i in range(n):
		ans += sorted_lst[i]
	print(ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.extend(b)
	ans = a[:n + m - 1]
	ans.sort()
	ans.append(a[n + m - 1])
	ans.reverse()
	print(sum(ans[:n]))


nos = int(input())
for i in range(nos):
	sums = 0
	(n, m) = map(int, input().split())
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l3 = l1 + l2[:len(l2) - 1]
	l3.sort(reverse=True)
	for i in range(n - 1):
		sums += l3[i]
	sums += l2[len(l2) - 1]
	print(sums)


import heapq
k = int(input())
for _ in range(k):
	(n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar2 = list(map(int, input().split()))
	heapq.heapify(ar)
	for i in range(m):
		heapq.heappop(ar)
		heapq.heappush(ar, ar2[i])
	print(sum(ar))


for _ in range(int(input())):
	[n, m] = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	a = a[1:]
	k = b[-1]
	a += b[:-1]
	a.sort(reverse=True)
	print(sum(a[:n - 1]) + k)


from heapq import heapify, heappush, heappop
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	boards = list(map(int, input().split()))
	op = list(map(int, input().split()))
	heapify(boards)
	for i in op:
		heappop(boards)
		heappush(boards, i)
	print(sum(boards))


import heapq
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	heapq.heapify(arr1)
	for num in arr2:
		heapq.heapreplace(arr1, num)
	print(sum(arr1))


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	last = l2[-1]
	l1 = sorted(l1, reverse=True)
	ans = 0
	if n > m:
		l2 = sorted(l2[0:m - 1] + l1[:], reverse=True)
		ans = sum(l2[:n - 1]) + last
	else:
		l2 = sorted(l2[0:m - 1] + l1[:], reverse=True)
		ans = sum(l2[0:n - 1]) + last
	print(ans)


t = int(input())
for p in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	count = sum(a) + b[-1] - a[0]
	b = b[:-1]
	b.sort(reverse=True)
	i = 1
	while i != m and i != n:
		if a[i] < b[i - 1]:
			count = count - a[i] + b[i - 1]
		else:
			break
		i += 1
	print(count)


import os, sys, io, math
from re import *
from math import *
from array import *
from heapq import *
from bisect import *
from functools import *
from itertools import *
from statistics import *
from collections import *
I = lambda : [*map(int, sys.stdin.readline().split())]
IP = lambda : map(int, input().split())
IS = lambda : input()
IN = lambda : int(input())
IF = lambda : float(input())
for _ in range(IN()):
	(n, r) = IP()
	(a, b) = (I(), I())
	m = b[-1]
	b.remove(b[-1])
	l = a + b
	l.sort(reverse=True)
	l.insert(0, m)
	print(sum(l[:n]))


import sys
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

def readInt():
	return int(input())

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

def readStringList():
	return list(input())

def readStringListWithSpace():
	return list(input().split())

def readString():
	return input()

def execute():
	import heapq
	for _ in range(readInt()):
		(n, m) = readIntList()
		arr = readIntList()
		q = readIntList()
		heapq.heapify(arr)
		for i in q:
			heapq.heappop(arr)
			heapq.heappush(arr, i)
		print(sum(arr))
execute()


import os
import math
import collections
import bisect
import functools
import itertools
import heapq

def solve(a, b, n, m):
	heapq.heapify(a)
	for x in b:
		heapq.heappop(a)
		heapq.heappush(a, x)
	return sum(a)
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(a, b, n, m))


import heapq
for tes in range(int(input())):
	(n, p) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	heapq.heapify(A)
	for b in B:
		heapq.heappop(A)
		heapq.heappush(A, b)
	print(sum(A))


for i in range(0, int(input())):
	(n, m) = [int(i) for i in input().split()]
	q = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	q += a
	q.sort()
	q = q[m:]
	if not a[-1] in q:
		q[0] = a[-1]
	print(sum(q))


import heapq
t = int(input())
for z in range(t):
	(n, m) = list(map(int, input().split()))[:2]
	a = list(map(int, input().split()))[:n]
	b = list(map(int, input().split()))[:m]
	heapq.heapify(a)
	for i in b:
		heapq.heappop(a)
		heapq.heappush(a, i)
	print(sum(a))


import heapq
from bisect import bisect_left
for q in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	lis = []
	for item in arr:
		heapq.heappush(lis, item)
	for i in range(m):
		heapq.heappop(lis)
		heapq.heappush(lis, b[i])
	print(sum(lis))


from heapq import heapify, heappush, heappop

def max_sum(a, b, n, m):
	heapify(a)
	for item in b:
		heappop(a)
		heappush(a, item)
	sum = 0
	for item in a:
		sum += item
	return sum
t = int(input())
while t:
	(n, m) = [int(item) for item in input().split(' ')]
	a = [int(item) for item in input().split(' ')]
	b = [int(item) for item in input().split(' ')]
	print(max_sum(a, b, n, m))
	t -= 1


import heapq

def operation(arrayA, arrayB, a, b):
	heapq.heapify(arrayA)
	for i in range(int(b)):
		top = heapq.heappop(arrayA)
		heapq.heappush(arrayA, arrayB[i])
		arrayB[i] = top
	return sum(arrayA)
numOfInputs = int(input())
for i in range(numOfInputs):
	(a, b) = input().split()
	arrayA = [int(x) for x in input().split()]
	arrayB = [int(x) for x in input().split()]
	print(operation(arrayA, arrayB, a, b))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	mm = l2[-1]
	l2.remove(l2[-1])
	l = l1 + l2
	l.sort(reverse=True)
	l.insert(0, mm)
	print(sum(l[:n]))


from heapq import heappush, heappop
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	replace = list(map(int, input().split()))
	for va in replace:
		heappop(arr)
		heappush(arr, va)
	print(sum(arr))


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
from heapq import *
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

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

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

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = inp()
for i in range(t):
	(n, m) = mp()
	a = li()
	b = li()
	k = b.pop()
	a.sort()
	b.sort(reverse=True)
	a[0] = k
	j = 0
	for i in range(1, len(a)):
		if j < len(b) and a[i] < b[j]:
			a[i] = b[j]
			j += 1
	print(sum(a))


import heapq
tests = int(input())
for i in range(tests):
	(n, m) = map(int, input().split())
	nums = list(map(int, input().split()))
	changes = list(map(int, input().split()))
	heapq.heapify(nums)
	for j in range(m):
		heapq.heappop(nums)
		heapq.heappush(nums, changes[j])
	print(sum(nums))


import heapq
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	heapq.heapify(a)
	for bj in b:
		heapq.heappop(a)
		heapq.heappush(a, bj)
	print(sum(a))


import sys
import collections
from math import ceil, gcd, sqrt, log
import bisect
import heapq
INF = float('inf')
mod = 1000000007

def solve():
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	minHeap = []
	for i in A:
		heapq.heappush(minHeap, i)
	for a in B:
		heapq.heappop(minHeap)
		heapq.heappush(minHeap, a)
	print(sum(minHeap))
t = int(input())
while t != 0:
	solve()
	t -= 1


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from collections import Counter
from bisect import bisect_left as bl, bisect_right as br
import heapq
sys.setrecursionlimit(100000000)
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
for _ in range(int(input())):
	(n, m) = mul()
	a = seq()
	b = seq()
	heapq.heapify(a)
	for i in b:
		heapq.heappop(a)
		heapq.heappush(a, i)
	print(sum(a))


from heapq import *
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	h = []
	for i in l:
		heappush(h, i)
	l = list(map(int, input().split()))
	for i in l:
		x = heappop(h)
		heappush(h, i)
	print(sum(h))


from heapq import heapify, heappop, heappush
for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	heapify(a)
	for i in range(m):
		heappop(a)
		heappush(a, b[i])
	print(sum(a))


from heapq import *
tests = int(input())
for _ in range(tests):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	heapify(a)
	b.reverse()
	while b:
		ai = heappop(a)
		heappush(a, b.pop())
	print(sum(a))


in_il = lambda : list(map(int, input().split()))
in_sl = lambda : input().split()
in_i = lambda : int(input())
MAX_INT = float('inf')
import heapq

def solve():
	(n, m) = in_il()
	a = in_il()
	b = in_il()
	heapq.heapify(a)
	for num in b:
		heapq.heappop(a)
		heapq.heappush(a, num)
	print(sum(a))
for _ in range(in_i()):
	solve()


import heapq

def solve(lst1, lst2):
	heapq.heapify(lst1)
	for i in range(len(lst2)):
		x = lst2[i]
		y = heapq.heappop(lst1)
		heapq.heappush(lst1, x)
	return sum(lst1)
for _ in range(int(input())):
	input()
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	print(solve(lst1, lst2))


import heapq
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	heapq.heapify(a)
	for j in b:
		x = heapq.heappop(a)
		heapq.heappush(a, j)
	print(sum(a))


from heapq import *
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	h = []
	for ele in a:
		heappush(h, ele)
	for ele in b:
		_ = heappop(h)
		heappush(h, ele)
	print(sum(h))


import heapq
t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	heapq.heapify(a)
	for i in range(m):
		tmp = heapq.heappop(a)
		heapq.heappush(a, b[i])
	print(sum(a))


from heapq import heappush, heappop, heapify
num = int(input())
for _ in range(num):
	(n, m) = map(int, input().split())
	aa = sorted(list(map(int, input().split())))
	bb = list(map(int, input().split()))
	heapify(aa)
	for i in bb:
		heappop(aa)
		heappush(aa, i)
	print(sum(aa))


import heapq
import math
eps = 10 ** (-9)

def solve():
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = input().split()
	b = input().split()
	a = [int(x) for x in a]
	b = [int(x) for x in b]
	heapq.heapify(a)
	for x in b:
		heapq.heappop(a)
		heapq.heappush(a, x)
	print(sum(a))
	return
t = int(input())
for _ in range(t):
	solve()


import heapq
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	hp = []
	for e in arr:
		heapq.heappush(hp, e)
	for e in brr:
		a = heapq.heappop(hp)
		heapq.heappush(hp, e)
	print(sum(hp))


import heapq
test = int(input())
for _ in range(test):
	(n, m) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	heapq.heapify(arr)
	change = [int(x) for x in input().split()]
	for i in change:
		heapq.heappop(arr)
		heapq.heappush(arr, i)
	print(sum(arr))


t = int(input())
import heapq
for i in range(t):
	(n, m) = (int(x) for x in input().split(' '))
	a_n = [int(x) for x in input().split(' ')]
	a_m = [int(x) for x in input().split(' ')]
	heapq.heapify(a_n)
	for el in a_m:
		heapq.heapreplace(a_n, el)
	print(sum(a_n))


import math
import sys
from collections import Counter, defaultdict, deque
import heapq

def solve():
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	heap = []
	heapq.heapify(heap)
	for i in range(0, n):
		heapq.heappush(heap, arr[i])
	for j in range(m):
		minValue = heapq.heappop(heap)
		heapq.heappush(heap, brr[j])
	maxSum = 0
	for i in heap:
		maxSum += i
	return maxSum
t = int(input())
while t:
	print(solve())
	t -= 1


from typing import List
from bisect import *
from collections import *
from functools import *
from itertools import *
from math import *
from queue import PriorityQueue
INF = 2 ** 64 - 1
MOD = 10 ** 9 + 7
mi = lambda : map(int, input().split())
li = lambda : list(mi())

def main2(n, m, a, b):
	stack = PriorityQueue()
	for v in a:
		stack.put(v)
	for i in range(m):
		curr = stack.get()
		stack.put(b[i])
	ans = 0
	while stack.empty() == False:
		ans += stack.get()
	print(ans)
	return

def main(n, m, a, b):
	all = []
	for i in range(n):
		all.append(a[i])
	for i in range(m - 1):
		all.append(b[i])
	all.sort(reverse=True)
	ans = b[m - 1]
	for i in range(n - 1):
		ans += all[i]
	print(ans)
	return
caseNum = int(input())
for i in range(0, caseNum):
	(n, m) = li()
	a = li()
	b = li()
	main(n, m, a, b)


from heapq import heapify, heappop, heappush

def solution():
	(n, m) = (int(num) for num in input().split())
	a = [int(num) for num in input().split()]
	b = [int(num) for num in input().split()]
	heapify(a)
	for num in b:
		heappop(a)
		heappush(a, num)
	print(sum(a))

def main():
	t = int(input())
	while t:
		solution()
		t -= 1
main()


import heapq
n = int(input())

def solve(n, m, a, b):
	heapq.heapify(a)
	for item in b:
		heapq.heappop(a)
		heapq.heappush(a, item)
	return sum(a)
for _ in range(n):
	(n, m) = [int(_) for _ in input().split()]
	a = [int(_) for _ in input().split()]
	b = [int(_) for _ in input().split()]
	print(solve(n, m, a, b))


def helper(arr, arr2):
	arr = sorted(arr)
	import heapq
	minH = []
	ans = sum(arr)
	for num in arr:
		heapq.heappush(minH, num)
	for i in range(len(arr2)):
		small = heapq.heappop(minH)
		ans += arr2[i] - small
		heapq.heappush(minH, arr2[i])
	return ans
for i in range(int(input())):
	lst = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	arr2 = list(map(int, input().split(' ')))
	print(helper(arr, arr2))


import heapq as hq
for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split(' ')]
	arr = [int(x) for x in input().split(' ')]
	brr = [int(x) for x in input().split(' ')]
	heap = []
	for x in arr:
		hq.heappush(heap, x)
	for x in brr:
		hq.heappop(heap)
		hq.heappush(heap, x)
	print(sum(heap))


import heapq
from collections import defaultdict, Counter
import bisect
graph = defaultdict(set)

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

def solve(a, b):
	res = 0
	heapq.heapify(a)
	heapq.heappop(a)
	heapq.heappush(a, b[0])
	res = sum(a)
	sum_ = res
	for i in range(1, len(b)):
		minimum = heapq.heappop(a)
		sum_ = sum_ + b[i] - minimum
		res = max(res, sum_)
		heapq.heappush(a, b[i])
	return sum(a)
for _ in range(int(input())):
	(n, m) = listinput()
	a = listinput()
	b = listinput()
	print(solve(a, b))


import heapq

def heappush(heap, item):
	return heapq.heappush(heap, item)

def heappop(heap):
	return heapq.heappop(heap)
t = int(input())
while t:
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	mm = []
	heapq.heapify(mm)
	for i in a:
		heappush(mm, i)
	for i in b:
		heappop(mm)
		heappush(mm, i)
	print(sum(mm))
	t = t - 1


import heapq
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	heapq.heapify(a)
	s = sum(a)
	for i in range(m):
		s -= heapq.heappop(a)
		heapq.heappush(a, b[i])
		s += b[i]
	print(s)


import heapq
t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	heapq.heapify(A)
	ret = sum(A)
	for i in range(m):
		temp = heapq.heappop(A)
		tt = B[i] - temp
		ret += tt
		heapq.heappush(A, B[i])
	print(ret)
	t -= 1


import heapq as hq
t = int(input())
for tests in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pq = [i for i in a]
	hq.heapify(pq)
	for i in b:
		cur = hq.heappop(pq)
		hq.heappush(pq, i)
	res = 0
	while len(pq):
		res += hq.heappop(pq)
	print(res)


import math
import heapq
from collections import *
import math

def solve():
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	pq = []
	for i in range(n):
		heapq.heappush(pq, a[i])
	for i in range(m):
		heapq.heappop(pq)
		heapq.heappush(pq, b[i])
	print(sum(pq))
t = int(input())
for _ in range(t):
	solve()


import bisect

def insert(list, n):
	bisect.insort(list, n)
	return list
t = int(input())
for z in range(t):
	nm = input().split(' ')
	n = int(nm[0])
	m = int(nm[1])
	data1 = input().split(' ')
	data2 = input().split(' ')
	s = 0
	for i in range(n):
		data1[i] = int(data1[i])
		s += data1[i]
	for i in range(m):
		data2[i] = int(data2[i])
	data1.sort()
	for i in range(m):
		s -= data1[0]
		data1.pop(0)
		s += data2[i]
		data1 = insert(data1, data2[i])
	print(s)


for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	(ar1, ar2) = (list(map(int, input().split())), list(map(int, input().split())))
	for i in ar2:
		ar1.sort()
		ar1 = ar1[1:]
		ar1.append(i)
	print(sum(ar1))


for _ in range(int(input())):
	(n, m) = [int(_) for _ in input().split()]
	X = sorted([int(_) for _ in input().split()])
	Y = [int(_) for _ in input().split()]
	for _ in Y:
		X.pop(0)
		X.append(_)
		X.sort()
	print(sum(X))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	la = list(map(int, input().split()))
	bl = list(map(int, input().split()))
	while len(bl):
		la.sort()
		la.pop(0)
		la.append(bl[0])
		bl.pop(0)
	print(sum(la))


import sys
sys.setrecursionlimit(10 ** 9)
for i in range(int(input())):
	L1 = list(map(int, input().split()))
	L2 = list(map(int, input().split()))
	L3 = list(map(int, input().split()))
	for j in range(L1[1]):
		L2.sort()
		L2 = L2[1:]
		L2 += [L3[j]]
	print(sum(L2))


t = int(input())
for _ in range(t):
	input()
	nlst = list(map(int, input().split()))
	mlst = list(map(int, input().split()))
	for x in mlst:
		nlst[nlst.index(min(nlst))] = x
	print(sum(nlst))


import sys

def solve():
	inp = sys.stdin.readline
	(n, m) = map(int, inp().split())
	a = list(map(int, inp().split()))
	b = list(map(int, inp().split()))
	for it in range(len(b)):
		mn = min(a)
		pos = a.index(mn)
		a[pos] = b[it]
	ans = sum(a)
	print(ans)

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(m):
		mini = min(a)
		el = a.index(mini)
		a[el] = b[j]
	print(sum(a))


R = lambda : map(int, input().split())
(t,) = R()
while t:
	t -= 1
	R()
	(*a,) = R()
	for x in R():
		a[a.index(min(a))] = x
	print(sum(a))


import sys
n = int(sys.stdin.readline())
for _ in range(n):
	(n, m) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	ans = 0
	for i in b:
		a[a.index(min(a))] = i
	print(sum(a))


import sys

def comp(x, y):
	return x <= y

def solve():
	inp = sys.stdin.readline
	(n, m) = map(int, inp().split())
	a = list(map(int, inp().split()))
	b = list(map(int, inp().split()))
	for x in b:
		mn = min(a)
		pos = a.index(mn)
		a[pos] = x
	print(sum(a))

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


import sys

def solve():
	(n, m) = map(int, sys.stdin.readline().split())
	va = sorted(map(int, sys.stdin.readline().split()))
	vb = map(int, sys.stdin.readline().split())
	for i in vb:
		va[va.index(min(va))] = i
	print(sum(va))

def main():
	n = int(sys.stdin.readline())
	for _ in range(n):
		solve()
main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for el in b:
		i = a.index(min(a))
		a[i] = el
	print(sum(a))


import sys

def solve():
	inp = sys.stdin.readline
	(n, m) = map(int, inp().split())
	a = list(map(int, inp().split()))
	b = list(map(int, inp().split()))
	for v in b:
		x = min(a)
		pos = a.index(x)
		a[pos] = v
	print(sum(a))

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()