You are given two arrays $a$ and $b$ both consisting of $n$ positive (greater than zero) integers. You are also given an integer $k$.

In one move, you can choose two indices $i$ and $j$ ($1 \le i, j \le n$) and swap $a_i$ and $b_j$ (i.e. $a_i$ becomes $b_j$ and vice versa). Note that $i$ and $j$ can be equal or different (in particular, swap $a_2$ with $b_2$ or swap $a_3$ and $b_9$ both are acceptable moves).

Your task is to find the maximum possible sum you can obtain in the array $a$ if you can do no more than (i.e. at most) $k$ such moves (swaps).

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 200$) — the number of test cases. Then $t$ test cases follow.

The first line of the test case contains two integers $n$ and $k$ ($1 \le n \le 30; 0 \le k \le n$) — the number of elements in $a$ and $b$ and the maximum number of moves you can do. The second line of the test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 30$), where $a_i$ is the $i$-th element of $a$. The third line of the test case contains $n$ integers $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 30$), where $b_i$ is the $i$-th element of $b$.


-----Output-----

For each test case, print the answer — the maximum possible sum you can obtain in the array $a$ if you can do no more than (i.e. at most) $k$ swaps.


-----Example-----
Input
5
2 1
1 2
3 4
5 5
5 5 6 6 5
1 2 5 4 3
5 3
1 2 3 4 5
10 9 10 10 9
4 0
2 2 4 3
2 4 2 3
4 4
1 2 2 1
4 4 5 4

Output
6
27
39
11
17



-----Note-----

In the first test case of the example, you can swap $a_1 = 1$ and $b_2 = 4$, so $a=[4, 2]$ and $b=[3, 1]$.

In the second test case of the example, you don't need to swap anything.

In the third test case of the example, you can swap $a_1 = 1$ and $b_1 = 10$, $a_3 = 3$ and $b_3 = 10$ and $a_2 = 2$ and $b_4 = 10$, so $a=[10, 10, 10, 4, 5]$ and $b=[1, 9, 3, 2, 9]$.

In the fourth test case of the example, you cannot swap anything.

In the fifth test case of the example, you can swap arrays $a$ and $b$, so $a=[4, 4, 5, 4]$ and $b=[1, 2, 2, 1]$.

Difficulty: EASY
Tags: Sorting

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
def quick_sort(array):
	left = []
	equal = []
	right = []
	if len(array) > 1:
		pivot = array[0]
		for x in array:
			if x < pivot:
				left.append(x)
			elif x == pivot:
				equal.append(x)
			else:
				right.append(x)
		return quick_sort(left) + equal + quick_sort(right)
	else:
		return array

def Two_arrays_swap():
	cases = int(input())
	k = []
	arrayA = []
	arrayB = []
	for i in range(cases):
		k.append(list(map(int, input().split())))
		arrayA.append(list(map(int, input().split())))
		arrayB.append(list(map(int, input().split())))
		arrayA[i] = quick_sort(arrayA[i])
		arrayB[i] = quick_sort(arrayB[i])
	for i in range(len(arrayA)):
		if arrayA[i][0] > arrayB[i][-1] or k[i][1] == 0:
			print(sum(arrayA[i]))
			continue
		done = False
		while not done:
			for j in range(len(arrayA[i])):
				if arrayA[i][j] > arrayB[i][-j - 1]:
					print(sum(arrayA[i]))
					done = True
					break
				arrayA[i][j] = arrayB[i][-j - 1]
				k[i][1] -= 1
				if k[i][1] == 0:
					print(sum(arrayA[i]))
					done = True
					break
Two_arrays_swap()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c1 = sorted(map(int, input().split()))
	c2 = sorted(map(int, input().split()), reverse=True)
	for i in range(min(a, b)):
		if c1[i] < c2[i]:
			(c1[i], c2[i]) = (c2[i], c1[i])
		else:
			break
	print(sum(c1))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = []
	b = []
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	j = 0
	while k > 0 and j < n:
		if a[j] <= b[j]:
			(a[j], b[j]) = (b[j], a[j])
			k -= 1
		j += 1
	print(sum(a))


def small_idx(v):
	sml = v[0]
	sml_idx = 0
	for (i, e) in enumerate(v):
		if e < sml:
			sml = e
			sml_idx = i
	return (sml, sml_idx)

def lrg_idx(v):
	lrg = v[0]
	lrg_idx = 0
	for (i, e) in enumerate(v):
		if e > lrg:
			lrg = e
			lrg_idx = i
	return (lrg, lrg_idx)
t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	while k > 0:
		(a_s, a_s_i) = small_idx(a)
		(b_l, b_l_i) = lrg_idx(b)
		if a_s > b_l:
			break
		(a[a_s_i], b[b_l_i]) = (b_l, a_s)
		k -= 1
	print(sum(a))
	t -= 1


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = []
	a.sort()
	b.sort(reverse=True)
	if a[0] > b[0]:
		print(sum(a))
		t -= 1
		continue
	s = 0
	for i in range(n):
		if k > 0:
			if a[i] >= b[i]:
				s += a[i]
				continue
			else:
				s += b[i]
				k -= 1
				continue
		s += a[i]
	print(s)
	t -= 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for u in range(k):
		if min(a) > max(b):
			break
		x = a[a.index(min(a))]
		y = b[b.index(max(b))]
		(a[a.index(min(a))], b[b.index(max(b))]) = (y, x)
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		a.sort()
		b.sort()
		if a[0] < b[-1]:
			t = a[0]
			a[0] = b[-1]
			b[-1] = t
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	brr = [int(x) for x in input().split()]
	brr = sorted(brr, reverse=True)
	arr.sort()
	for i in range(k):
		if arr[i] < brr[i]:
			(arr[i], brr[i]) = (brr[i], arr[i])
	print(sum(arr))


outputs = []
for __ in range(int(input())):
	(N, K) = list(map(int, input().split()))
	a = [int(num) for num in input().split()]
	b = [int(num) for num in input().split()]
	a.sort()
	b = sorted(b, reverse=True)
	i = 0
	while i < N and K > 0 and (a[i] <= b[i]):
		if a[i] < b[i]:
			a[i] += b[i]
			b[i] = a[i] - b[i]
			a[i] -= b[i]
			K -= 1
		i += 1
	outputs.append(sum(a))
for output in outputs:
	print(output)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for K in range(k):
		a.sort()
		b.sort()
		b.reverse()
		if a[0] < b[0]:
			(a[0], b[0]) = (b[0], a[0])
	print(sum(a))


t = int(input())
i = 0
while i < t:
	(n, k) = map(int, input().split())
	a = list(sorted(map(int, input().split())))
	b = list(sorted(map(int, input().split())))
	j = 0
	x = 0
	z = n - 1
	while j < k:
		if a[x] < b[z]:
			aux = a[x]
			a[x] = b[z]
			b[z] = aux
		else:
			break
		x += 1
		z -= 1
		j += 1
	print(sum(a))
	i += 1


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	r = 0
	for i in range(n):
		if r >= k:
			break
		if b[n - i - 1] > a[i]:
			(a[i], b[n - i - 1]) = (b[n - i - 1], a[i])
		else:
			break
		r += 1
	print(sum(a))
	t -= 1


from sys import stdin

def func():
	return
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, stdin.readline().split())))
	b = sorted(list(map(int, stdin.readline().split())), reverse=True)
	(i, j) = (0, 0)
	while k > 0:
		if a[i] < b[j]:
			a[i] = b[j]
			j += 1
			i += 1
			k -= 1
		else:
			break
	print(sum(a))


import math
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
for _ in range(IN()):
	(n, k) = MAP()
	a = LI()
	b = LI()
	c = sorted(a)
	d = sorted(b)
	for i in range(k):
		if d[len(d) - i - 1] >= c[i]:
			(c[i], d[len(d) - i - 1]) = (d[len(d) - i - 1], c[i])
	print(sum(c))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	su = 0
	for i in range(k):
		if b[-1 * (i + 1)] > a[i]:
			a[i] = b[-1 * (i + 1)]
	print(sum(a))


def maxA(k, a, b):
	a.sort()
	b.sort()
	n = len(a)
	for i in range(k):
		if a[i] < b[n - 1 - i]:
			(b[n - 1 - i], a[i]) = (a[i], b[n - 1 - i])
	return sum(a)
t = int(input())
mat = []
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(j) for j in input().split()]
	b = [int(k) for k in input().split()]
	print(maxA(k, a, b))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a = sorted(a)
	b = sorted(b, reverse=True)
	for raz in range(k):
		if a[raz] < b[raz]:
			a[raz] = b[raz]
		else:
			break
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l.sort()
	l2.sort(reverse=True)
	sum = 0
	for i in range(min(k, n)):
		sum += max(l2[i], l[i])
	for i in range(k, n):
		sum += l[i]
	print(sum)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

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

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

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

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
t = INT()
while t != 0:
	(n, k) = MAP()
	a = LIST()
	b = LIST()
	for i in range(n):
		b[i] = -b[i]
	heapify(a)
	heapify(b)
	while k > 0:
		a1 = nsmallest(1, a)[0]
		b1 = nsmallest(1, b)[0]
		if a1 >= -1 * b1:
			break
		heappop(a)
		heappop(b)
		heappush(a, -b1)
		heappush(b, -a1)
		k -= 1
	print(sum(a))
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	moves = 0
	total = sum(a)
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < k and a[i] < b[i]:
		total -= a[i]
		total += b[i]
		i += 1
	print(total)


t = int(input())
while t:
	t -= 1
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	b.reverse()
	for i in range(k):
		if a[i] >= b[i]:
			break
		else:
			a[i] = b[i]
	print(sum(a))


def swap(i, j, a, b):
	temp = a[i]
	temp2 = b[j]
	b[j] = temp
	a[i] = temp2
	return (a, b)
a = int(input())
for ufui in range(a):
	lst = input().split()
	lst = [int(i) for i in lst]
	a = input().split()
	a = [int(i) for i in a]
	b = input().split()
	b = [int(i) for i in b]
	for p in range(lst[1]):
		val = min(a)
		ind1 = a.index(val)
		val2 = max(b)
		ind2 = b.index(val2)
		if val < val2:
			final = swap(ind1, ind2, a, b)
			a = final[0]
			b = final[1]
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	i = 0
	count = 0
	while i < n and count < k:
		if b[i] > a[i]:
			temp = a[i]
			a[i] = b[i]
			b[i] = temp
			count += 1
		if count >= k:
			break
		i += 1
	print(sum(a))


import sys
input = sys.stdin.readline

def main():
	for t in range(int(input())):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a.sort()
		b.sort()
		while a[0] < b[n - 1] and k > 0:
			x = b[n - 1]
			b[n - 1] = a[0]
			a[0] = x
			a.sort()
			b.sort()
			k -= 1
		print(sum(a))
main()


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split(' ')))
	B = list(map(int, input().split(' ')))
	A.sort()
	B.sort(reverse=True)
	for j in range(k):
		if A[j] >= B[j]:
			break
		else:
			A[j] = B[j]
	S = sum(A)
	print(S)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	while k > 0:
		if a[i] >= b[j]:
			break
		else:
			a[i] = b[j]
			i += 1
			j -= 1
			k -= 1
	ans = 0
	for ele in a:
		ans += ele
	print(ans)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		x = a.index(min(a))
		y = b.index(max(b))
		if a[x] < b[y]:
			(a[x], b[y]) = (b[y], a[x])
	print(sum(a))


A = lambda : map(int, input().split())
(t,) = A()
for _ in [0] * t:
	(n, k) = A()
	print(sum(map(max, sorted(A()), sorted(A())[:-1 - k:-1] + [0] * n)))


def main():
	T = int(input())
	a = []
	b = []
	temp = []
	for i in range(T):
		(n, k) = map(int, input().split())
		a = [int(i) for i in input().split()]
		b = [int(i) for i in input().split()]
		for i in range(k):
			max_b = max(b)
			min_a = min(a)
			max_a = max(a)
			min_b = min(b)
			if min_a < max_b:
				for i in range(len(a)):
					if a[i] == min_a:
						a[i] = max_b
						break
				for i in range(len(b)):
					if b[i] == max_b:
						b[i] = min_a
						break
		sum_a = 0
		for i in range(len(a)):
			sum_a += a[i]
		print(sum_a)
main()


time = int(input())
for t in range(time):
	(n, g) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	for i in range(g):
		if a[0] < b[-1]:
			w = a.pop(0)
			q = b.pop()
			a.append(q)
			b.insert(0, w)
		else:
			break
	print(sum(a))


import math
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	l = [i for i in b[:k]]
	for j in l:
		if min(a) < j:
			a.remove(a[0])
			a.append(j)
	print(sum(a))


def b():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for _ in range(k):
		maior_b = max(b)
		menor_a = min(a)
		indice_menor_a = a.index(menor_a)
		if maior_b > menor_a:
			a[indice_menor_a] = maior_b
			b.remove(maior_b)
	print(sum(a))

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


t = int(input())
count = 0
while count < t:
	count += 1
	l = list(map(int, input().split(' ')))
	n = l[0]
	k = l[1]
	l = list(map(int, input().split(' ')))
	l2 = list(map(int, input().split(' ')))
	ans = sum(l)
	while k > 0 and min(l) < max(l2):
		k -= 1
		ans -= l.pop(l.index(min(l)))
		ans += l2.pop(l2.index(max(l2)))
	print(ans)


t = int(input())
for i in range(t):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	a = input().split()
	a = [int(x) for x in a]
	b = input().split()
	b = [int(x) for x in b]
	for j in range(k):
		if min(a) < max(b):
			for i in a:
				if i == min(a):
					a.remove(min(a))
					break
			for w in b:
				if w == max(b):
					a.append(max(b))
					b.remove(max(b))
					break
	print(sum(a))


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, K) = getInts()
	A = getInts()
	B = getInts()
	A.sort(reverse=True)
	B.sort()
	ans = sum(A)
	while K:
		K -= 1
		if B[-1] > A[-1]:
			x = B.pop()
			y = A.pop()
			ans += x - y
		else:
			break
	return ans
for _ in range(getInt()):
	print(solve())


t = int(input())
for i in range(t):
	q = input()
	lst = q.split()
	n = int(lst[0])
	k = int(lst[1])
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	a.sort()
	b.sort()
	x = 0
	for j in range(k):
		if a[x] < b[-x - 1]:
			a[x] = b[-x - 1]
		else:
			break
		x += 1
	print(sum(map(int, a)))


t = int(input())
for case in range(t):
	(n, k) = map(int, input().split(' '))
	List_a = [int(j) for j in input().split(' ')]
	List_b = [int(j) for j in input().split(' ')]
	List_a.sort()
	List_b.sort()
	sum_a = sum(List_a)
	List_c = [sum_a]
	for i in range(k):
		List_a[i] = List_b[n - i - 1]
		List_c.append(sum(List_a))
	print(max(List_c))


t = int(input())
while t:
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	(i, j) = (0, 0)
	while k:
		if a[i] < b[i]:
			a[i] = b[i]
			i += 1
			j += 1
		else:
			j += 1
		k -= 1
	print(sum(a))
	t -= 1


from sys import stdin, stdout
import math
from collections import defaultdict
input = stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	res = 0
	i = n - 1
	j = n - 1
	cn = 0
	while i >= 0 and j >= 0:
		if k == 0 or cn == n:
			break
		if a[i] >= b[j]:
			res += a[i]
			a.pop()
			i -= 1
			cn += 1
		elif a[i] < b[j]:
			res += b[j]
			j -= 1
			k -= 1
			cn += 1
	a.sort(reverse=True)
	if cn < n:
		terms = n - cn
		res += sum(a[:terms])
	print(res)


import math
from collections import deque
import sys
sys.setrecursionlimit(10 ** 4)

def Divisors(n):
	l = []
	i = 2
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
		i = i + 1
	return l

def SieveOfEratosthenes(n):
	l = []
	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
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

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(i)
			n = n / i
	if n > 2:
		l.append(n)
	return l

def Factors(n):
	result = []
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if i == n / i:
				result.append(i)
			else:
				result.append(i)
				result.append(n // i)
	result.append(1)
	result.append(n)
	return result

def maxSubArraySum(a):
	max_so_far = 0
	max_ending_here = 0
	size = len(a)
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < abs(max_ending_here):
			max_so_far = max_ending_here
	return max_so_far

def longestsubarray(arr, n, k):
	current_count = 0
	max_count = 0
	for i in range(0, n, 1):
		if arr[i] % k != 0:
			current_count += 1
		else:
			current_count = 0
		max_count = max(current_count, max_count)
	return max_count

def main():
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	s = 0
	n1 = n
	p = n1 - 1
	q = n1 - 1
	while n1 > 0:
		if a[p] >= b[q] or k == 0:
			s += a[p]
			p -= 1
		elif k > 0:
			k -= 1
			s += b[q]
			q -= 1
		n1 -= 1
	print(s)
t = int(input())
for i in range(0, t):
	main()


t = int(input())
while t:
	[n, k] = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = sorted(a)
	b = sorted(b)
	j = len(b) - 1
	for i in range(k):
		if a[i] < b[j]:
			a[i] = b[j]
			j -= 1
	print(sum(a))
	t -= 1


def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		aa = sorted(map(int, input().split()))
		print(sum(map(max, aa[:k], sorted(map(int, input().split()), reverse=True))) + sum(aa[k:]))
main()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort()
	for i in range(k):
		if a[-1] >= b[-1]:
			break
		(a[-1], b[-1]) = (b[-1], a[-1])
		a.sort(reverse=True)
		b.sort()
	print(sum(a))


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))[::-1]
	base_sum = sum(a)
	for i in range(k):
		if min(a) < max(b):
			a.remove(min(a))
			a.append(max(b))
			b.remove(max(b))
	new_sum = sum(a)
	if base_sum > new_sum:
		print(base_sum)
	else:
		print(new_sum)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	s = sum(a)
	i = 0
	while k and a[i] < b[i]:
		k -= 1
		s += b[i] - a[i]
		i += 1
	print(s)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	for i in range(n):
		l.append([a[i], 0])
		l.append([b[i], 1])
	l.sort()
	l.reverse()
	p = 0
	s = 0
	for i in l:
		if p == n:
			break
		if i[1] == 1 and k <= 0:
			continue
		else:
			if i[1] == 1:
				k -= 1
			s += i[0]
			p += 1
	print(s)


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	for i in range(k):
		mn = min(a)
		idx = a.index(mn)
		mx = max(b)
		idx2 = b.index(mx)
		if mn < mx:
			(a[idx], b[idx2]) = (mx, mn)
		else:
			break
	print(sum(a))


import sys
input = sys.stdin.readline
t = int(input())
for r in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	counter = 0
	i = n - 1
	j = n - 1
	counter2 = 0
	ans = 0
	while counter2 < n:
		if a[i] >= b[j]:
			ans += a[i]
			i -= 1
			counter2 += 1
		elif counter < k:
			ans += b[j]
			j -= 1
			counter += 1
			counter2 += 1
		else:
			ans += a[i]
			i -= 1
			counter2 += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	ans = 0
	c = 0
	for i in range(n):
		if a[i] < b[i] and c < k:
			ans += b[i]
			c += 1
		else:
			ans += a[i]
	print(ans)


R = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, k) = R()
	a = sorted(R())[::-1]
	b = sorted(R())[::-1]
	a += (-1,)
	b += (-1,)
	i = j = s = 0
	while i + j < n:
		if a[i] < b[j] and k:
			k -= 1
			s += b[j]
			j += 1
		else:
			s += a[i]
			i += 1
	print(s)


def solution(n, k, a, b):
	b = sorted(b)
	a = a + (b[-k:] if k != 0 else [])
	a = sorted(a)
	return sum(a[-n:])
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	print(solution(n, k, a, b))


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()))
	l.sort()
	l1.sort(reverse=True)
	for j in range(m):
		if l[j] < l1[j]:
			(l1[j], l[j]) = (l[j], l1[j])
	ans = 0
	for j1 in range(n):
		ans += l[j1]
	print(ans)
	ans = 0


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		a1 = min(a)
		b1 = max(b)
		if b1 <= a1:
			break
		else:
			a[a.index(a1)] = b1
			b[b.index(b1)] = a1
	print(sum(a))


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr.sort()
	brr.sort()
	brr = brr[-1::-1]
	cnt = 0
	for i in range(k):
		if arr[cnt] < brr[cnt]:
			cnt += 1
			x = arr[i]
			arr[i] = brr[i]
			brr[i] = x
	print(sum(arr))


from functools import cmp_to_key
t = int(input())

def getP(a):
	pres = 0
	ret = []
	for ele in a:
		pres += ele
		ret.append(pres)
	return ret
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	pa = getP(a)
	pb = getP(b)
	ans = 0
	for i in range(0, k + 1):
		fa = n - i
		fb = i
		tans = 0
		if fa > 0:
			tans += pa[fa - 1]
		if fb > 0:
			tans += pb[fb - 1]
		ans = max(ans, tans)
	print(ans)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = sorted([int(n) for n in input().split()])
	d = sorted([int(m) for m in input().split()])
	e = d[-1::-1]
	f = []
	for j in range(b):
		if c[j] < e[j]:
			f.append(e[j])
		else:
			f.append(c[j])
	print(sum(f) + sum(c[b:]))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a1 = list(map(int, input().split()))
	b1 = list(map(int, input().split()))
	a1.sort()
	fans = 0
	b1.sort(reverse=True)
	for (i, j) in zip(a1, b1):
		if k > 0 and j > i:
			k -= 1
			fans += j
		else:
			fans += i
	print(fans)


inp = int(input())
for x in range(inp):
	counter = 0
	inp1 = list(map(int, input().split()))
	l = sorted(list(map(int, input().split())))
	l1 = sorted(list(map(int, input().split())), reverse=True)
	empt_lis = []
	for num in range(inp1[1]):
		if l[num] < l1[num]:
			l[num] = l1[num]
		else:
			break
	for element in l:
		counter += element
	print(counter)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	while k > 0 and b[j] > a[i]:
		(a[i], b[j]) = (b[j], a[i])
		i += 1
		j -= 1
		k -= 1
	sum = 0
	for item in a:
		sum += item
	print(sum)
	t -= 1


for t in range(int(input())):
	(n, k) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	if k == 0:
		print(sum(a))
	else:
		a.sort()
		b.sort()
		counter = 0
		for i in range(k):
			if b[-1] > a[counter]:
				a[counter] = b[-1]
				b.pop()
				counter += 1
		print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	c = sum(a[k:])
	for i in range(k):
		c += max(a[i], b[i])
	print(c)


import sys, math
from collections import defaultdict as dd
input = sys.stdin.readline
for i in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l1.sort()
	l2 = list(map(int, input().split()))
	l2.sort()
	l2 = l2[::-1]
	for i in range(m):
		if l1[0] < l2[0]:
			(l1[0], l2[0]) = (l2[0], l1[0])
			l1.sort()
			l2.sort()
			l2 = l2[::-1]
	print(sum(l1))


for _ in range(int(input())):
	(N, M) = map(int, input().split())
	L1 = list(map(int, input().split()))
	L2 = list(map(int, input().split()))
	L1.sort()
	L2.sort(reverse=True)
	for i in range(N):
		if L1[i] < L2[i] and M > 0:
			(L1[i], L2[i]) = (L2[i], L1[i])
			M -= 1
		else:
			break
	print(sum(L1))


tests = int(input())
while tests > 0:
	line = [int(x) for x in input().strip().split()]
	(n, k) = (line[0], line[1])
	a = [int(x) for x in input().strip().split()]
	b = [int(x) for x in input().strip().split()]
	a.sort()
	b.sort(reverse=True)
	l1 = a[k:]
	l2 = sorted(a[:k] + b[:k])[-k:]
	print(sum(l1 + l2))
	tests -= 1


i = int(input())
for _ in range(i):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	rty = 0
	while rty < k:
		l1min = min(l1)
		l2max = max(l2)
		if l1min < l2max:
			rty += 1
			aind = l1.index(l1min)
			bind = l2.index(l2max)
			tmp = l1[aind]
			l1[aind] = l2[bind]
			l2[bind] = tmp
		else:
			break
	print(sum(l1))


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k > 0:
		if min(a) >= max(b):
			break
		else:
			temp = a[a.index(min(a))]
			a[a.index(min(a))] = b[b.index(max(b))]
			b[b.index(max(b))] = temp
			k -= 1
	print(sum(a))


for i in range(0, int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b = b[::-1]
	j = 0
	kk = 0
	z = 0
	while j < n and b[j] > a[kk] and (z < k):
		if b[j] > a[kk]:
			(a[kk], b[j]) = (b[j], a[kk])
			j = j + 1
			kk = kk + 1
			z = z + 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	s = 0
	x = 0
	j = n - 1
	v = 0
	while v < k and x < n:
		if a[x] < b[j]:
			s += b[j]
			x += 1
			j -= 1
			v += 1
		else:
			break
	for c in range(x, n):
		s += a[c]
	print(s)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	s = sum(a)
	for i in range(k):
		if a[i] < b[i]:
			s += b[i] - a[i]
		else:
			break
	print(s)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	for i in range(k):
		if min(a) < max(b):
			(a[0], b[n - 1]) = (max(b), min(a))
			(a.sort(), b.sort())
	print(sum(a))


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	for _ in range(II()):
		(n, k) = MI()
		aa = LI()
		bb = LI()
		bb.sort(reverse=True)
		aa += bb[:k]
		aa.sort(reverse=True)
		print(sum(aa[:n]))
main()


for _ in range(int(input())):
	(lens, swap) = [int(x) for x in input().split()]
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(x) for x in input().split()], reverse=True)
	ans = 0
	for i in range(lens):
		if i < swap:
			ans += max(a[i], b[i])
		else:
			ans += a[i]
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] >= b[n - 1 - i]:
			break
		else:
			(a[i], b[n - 1 - i]) = (b[n - 1 - i], a[i])
	print(sum(a))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	r = 0
	if min(l1) >= max(l2):
		print(sum(l1))
	elif k == 0:
		print(sum(l1))
	else:
		for a in range(k):
			r = l1[l1.index(min(l1))]
			l1[l1.index(min(l1))] = l2[l2.index(max(l2))]
			l2[l2.index(max(l2))] = r
			if min(l1) >= max(l2):
				break
		print(sum(l1))


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


T = int(input())
while T != 0:
	T -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	count = 0
	ai_smaller = True
	if k == 0:
		print(sum(a))
	else:
		for i in range(len(a)):
			if a[i] < b[i]:
				a[i] = b[i]
				k -= 1
			if k == 0:
				break
			elif a[i] > b[i]:
				break
		print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = sorted(a)
	d = sorted(b, reverse=True)
	d = d[:k]
	for j in range(len(d)):
		if d[j] > c[j]:
			c[j] = d[j]
	print(sum(c))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort(reverse=True)
	for i in range(k):
		temp = 0
		if arr1[i] >= arr2[i]:
			break
		if arr1[i] < arr2[i]:
			temp = arr1[i]
			arr1[i] = arr2[i]
			arr2[i] = temp
	print(sum(arr1))


t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a, reverse=True)
	b = sorted(b, reverse=True)
	if k > 0:
		for i in range(k):
			if b[i] > a[-i - 1]:
				a[-i - 1] = b[i]
		s = sum(a)
	else:
		s = sum(a)
	print(s)


t = int(input())
for j in range(t):
	(n, k) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	a.sort()
	b.sort(reverse=True)
	m = sum(a)
	for i in range(k):
		(a[i], b[i]) = (b[i], a[i])
		if sum(a) > m:
			m = sum(a)
	print(m)


t = int(input())
for testcase in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort()
	a.sort()
	for i in range(k):
		a[i] = max(a[i], b[-i - 1])
	ans = sum(a)
	print(ans)


for _ in range(int(input())):
	a = input().split(' ')
	n = int(a[0])
	k = int(a[1])
	a = input().split(' ')
	b = input().split(' ')
	for i in range(n):
		a[i] = int(a[i])
		b[i] = int(b[i])
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if i > n:
			break
		elif a[i] >= b[i]:
			break
		else:
			a[i] = b[i]
	s = 0
	for i in a:
		s = s + i
	print(s)


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
t = 1
t = int(input())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	while k > 0:
		ma = a.index(min(a))
		mb = b.index(max(b))
		if a[ma] >= b[mb]:
			break
		(a[ma], b[mb]) = (b[mb], a[ma])
		k -= 1
	print(sum(a))


o = int(input())
for item in range(o):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	lst1 = [int(i) for i in input().split()]
	lst2 = [int(j) for j in input().split()]
	lst1.sort()
	lst2.sort()
	for r in range(b):
		if lst1[0] < lst2[-1]:
			lst1.pop(0)
			lst1.append(lst2[-1])
			lst2.pop(-1)
			lst1.sort()
	s = 0
	for u in lst1:
		s += u
	print(s)


for i in range(int(input())):
	(n, k) = input().split()
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()])
	for i in range(int(k)):
		if b[-1] > a[0]:
			b.insert(0, a.pop(0))
			a.append(b.pop(-1))
			a = sorted(a)
			b = sorted(b)
	print(sum(a))


t = int(input())
while t > 0:
	t = t - 1
	(n, k) = map(int, input().split())
	a = [int(a) for a in input().split()]
	b = [int(b) for b in input().split()]
	sum_a = 0
	A = sorted(a)
	B = sorted(b)
	for i in range(0, k):
		x = max(B)
		if x > min(A):
			A[i] = x
			B.pop(len(B) - 1)
		else:
			break
	for j in range(0, n):
		sum_a = sum_a + A[j]
	print(sum_a)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	res = sum(a)
	for i in range(k):
		if b[i] > a[i]:
			res += b[i] - a[i]
		else:
			break
	print(res)


def main_function():
	from sys import stdin
	from sys import stdout
	from bisect import insort_left
	input = stdin.readline
	print = stdout.write
	t = int(input())
	for _ in range(t):
		(n, k) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a.sort()
		b.sort()
		for i in range(k):
			insort_left(a, b[n - 1 - i])
		print(f'{sum(a[-n:])}\n')
main_function()


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for _ in range(k):
		a.sort()
		b.sort()
		if a[0] > b[-1]:
			continue
		(b[-1], a[0]) = (a[0], b[-1])
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	tmp = k
	for i in range(k):
		if a[i] > b[-i - 1]:
			tmp = i
			break
	ans = 0
	for i in range(tmp):
		ans += b[-i - 1]
	for i in range(tmp, n):
		ans += a[i]
	print(ans)


t = int(input())
for tt in range(t):
	(n, k) = [int(x) for x in input().split(' ')]
	a = sorted(list(map(int, input().split(' '))))
	b = sorted(list(map(int, input().split(' '))))
	b.reverse()
	ans = 0
	for i in range(n):
		if i < k:
			if b[i] > a[i]:
				ans += b[i]
			else:
				ans += a[i]
		else:
			ans += a[i]
	print(ans)


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	lst1 = [int(i) for i in input().split()]
	lst2 = [int(i) for i in input().split()]
	for i in range(0, k):
		a = min(lst1)
		b = max(lst2)
		if a < b:
			lst1.append(b)
			lst1.remove(a)
			lst2.remove(b)
		else:
			break
	print(sum(lst1))


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b = b[::-1]
	l = []
	i = 0
	j = 0
	s = 0
	while k > 0:
		if a[i] < b[i]:
			s = s + b[i]
			i += 1
		k -= 1
	for j in range(i, n):
		s = s + a[j]
	print(s)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	s = 0
	j = 0
	for i in range(n):
		if b[j] > a[i] and k:
			s += b[j]
			k -= 1
			j += 1
		else:
			s += a[i]
	print(s)


for _ in range(int(input())):
	x = input()
	x = x.split()
	(n, k) = (int(x[0]), int(x[1]))
	x = input()
	x = x.split()
	a = []
	for i in range(n):
		a.append(int(x[i]))
	x = input()
	x = x.split()
	b = []
	for i in range(n):
		b.append(int(x[i]))
	a.sort()
	b.sort(reverse=True)
	for i in range(n):
		if k == 0:
			break
		if len(b) > 0 and b[0] > a[i]:
			a[i] = b[0]
			k = k - 1
			b.pop(0)
	s = 0
	for i in a:
		s += i
	print(s)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	sum = 0
	i = 0
	j = x - 1
	while y != 0 and i != x and (j != -1):
		if a[i] < b[j]:
			a[i] = b[j]
			j -= 1
			i += 1
			y -= 1
		else:
			break
	for i in range(x):
		sum += a[i]
	print(sum)


def main():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a.sort()
		b.sort()
		for j in range(k):
			if b[::-1][j] <= a[j]:
				break
			a[j] = b[::-1][j]
		print(sum(a))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()])[::-1]
	ans = 0
	for i in range(k):
		if a[i] > b[i]:
			ans += a[i]
		else:
			ans += b[i]
	ans += sum(a[k:])
	print(ans)


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	b.sort()
	c.sort()
	k = a[1]
	j = 0
	l = len(c) - 1
	while k > 0:
		if c[l] > b[j]:
			(c[l], b[j]) = (b[j], c[l])
		k -= 1
		j += 1
		l -= 1
	print(sum(b))


for _ in range(int(input())):
	(n, h) = map(int, input().split())
	a = [*map(int, input().split())]
	b = [*map(int, input().split())]
	a.sort()
	b.sort(reverse=True)
	for i in range(h):
		if a[i] < b[i]:
			ss = a[i]
			a[i] = b[i]
			b[i] = ss
	print(sum(a))


t = int(input())
for i in range(t):
	[n, k] = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(a)
	c = 1
	while c <= k:
		am = min(a)
		bm = max(b)
		if am < bm:
			s = s - am + bm
			a.remove(am)
			a.append(bm)
			b.remove(bm)
			b.append(am)
			c += 1
		else:
			break
	print(s)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(y):
		if min(a) < max(b):
			a.remove(min(a))
			a.extend([max(b)])
			b.remove(max(b))
	print(sum(a))


def answer(n, k, a, b):
	if k == 0:
		return sum(a)
	a = sorted(a, reverse=False)
	b = sorted(b, reverse=True)
	for i in range(k):
		if a[i] >= b[i]:
			break
		(a[i], b[i]) = (b[i], a[i])
	return sum(a)
num_iter = int(input())
result = []
for _ in range(num_iter):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	result.append(answer(n, k, a, b))
print('\n'.join(map(str, result)))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	i = 0
	while i < k:
		if a[i] < b[i]:
			a[i] = b[i]
		i += 1
	print(sum(a))


def answer(n, k, A, B):
	A.sort()
	B.sort(reverse=True)
	for i in range(k):
		if A[i] < B[i]:
			A[i] = B[i]
		else:
			break
	return sum(A)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(answer(n, k, a, b))


def main():
	for _ in range(int(input())):
		(n, k) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		(s1, s2) = (sum(a), sum(b))
		for i in range(min(n, k)):
			if min(a) > max(b):
				break
			else:
				s1 += max(b)
				s1 -= min(a)
				b.remove(max(b))
				a.remove(min(a))
		print(s1)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	flag = True
	sum = 0
	for i in range(n):
		if i >= k:
			flag = False
		if a[i] > b[i]:
			flag = False
		if flag:
			sum += b[i]
		else:
			sum += a[i]
	print(sum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [(int(i), 1) for i in input().split()]
	b = [(int(i), 0) for i in input().split()]
	c = sorted(a + b, key=lambda x: x[0], reverse=True)
	l = []
	cnt = 0
	for (i, j) in c:
		if len(l) == n:
			break
		if j == 0:
			cnt += 1
		if cnt > k and j == 0:
			continue
		l.append(i)
	print(sum(l))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	while k != 0:
		if max(b) < min(a):
			break
		else:
			p = a.index(min(a))
			q = b.index(max(b))
			temp = a[p]
			a[p] = b[q]
			b[q] = temp
			k -= 1
	print(sum(a))


m = int(input())
for j in range(m):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b = b[::-1]
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
		else:
			break
	print(sum(a))


for x in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ai = 0
	bi = 0
	ki = 0
	while ki < k and bi < n:
		if a[ai] < b[bi]:
			(a[ai], b[bi]) = (b[bi], a[ai])
			ai += 1
			bi += 1
			ki += 1
		else:
			bi += 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if k == 0:
		print(sum(a))
		continue
	res = 0
	a.sort()
	b.sort(reverse=True)
	for pos in range(n):
		if pos < k:
			res += max(a[pos], b[pos])
		else:
			res += a[pos]
	print(res)


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if max(b) <= min(a) or k == 0:
		print(sum(a))
	else:
		for i in range(k):
			if max(b) <= min(a):
				print(sum(a))
				break
			else:
				t1 = max(b)
				t2 = min(a)
				a.remove(t2)
				b.remove(t1)
				a.append(t1)
				b.append(t2)
				if i == k - 1:
					print(sum(a))
t = int(input())
for i in range(t):
	solve()


t = int(input())
_nk = []
_a = []
_b = []
for i in range(t):
	(n, k) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	_nk.append([n, k])
	_a.append(a)
	_b.append(b)
for i in range(t):
	(n, k) = _nk[i]
	a = _a[i]
	b = _b[i]
	sum = 0
	for l in range(n):
		sum += a[l]
	for j in range(k):
		a.sort()
		b.sort()
		tmp = a[0]
		a[0] = b[n - 1]
		b[n - 1] = tmp
		current_sum = 0
		for l in range(n):
			current_sum += a[l]
		sum = max(sum, current_sum)
	print(sum)


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	i = 0
	while i < k and b[i] >= a[i]:
		a[i] = b[i]
		i += 1
	print(sum(a))


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	ld = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	x = k
	l1 = sorted(ld)
	l2.sort()
	l2.reverse()
	for i in range(n):
		if l2[i] > l1[i]:
			l1[i] = l2[i]
		k = k - 1
		if k <= 0:
			break
	if x == 0:
		print(sum(ld))
	else:
		print(sum(l1))


t = int(input())
for w in range(t):
	(n, k) = (int(i) for i in input().split())
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()], reverse=True)
	i = 0
	while i < k:
		if a[i] < b[i]:
			a[i] = b[i]
			i += 1
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = [int(a) for a in input().split()]
	B = [int(b) for b in input().split()]
	A.sort()
	B.sort(reverse=True)
	ans = 0
	swaps = 0
	for i in range(n):
		if A[i] >= B[i]:
			ans += A[i]
		elif swaps < k:
			ans += B[i]
			swaps += 1
		else:
			ans += A[i]
	print(ans)


import math
from collections import defaultdict, Counter, deque

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

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


for j in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	j1 = 0
	summ = sum(a)
	for i in range(n):
		if k == 0:
			break
		if a[i] < b[n - 1 - i]:
			j1 = i
			k -= 1
			l = a[i]
			a[i] = b[n - 1 - i]
			b[n - 1 - i] = l
	print(sum(a))


tc = int(input())
for i in range(tc):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	b.reverse()
	for j in range(k):
		if a[j] < b[j]:
			a[j] = b[j]
	print(sum(a))


t = int(input())
for i in range(t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		p = a.index(min(a))
		q = b.index(max(b))
		if a[p] < b[q]:
			temp = a[p]
			a[p] = b[q]
			b[q] = temp
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	b2 = list(map(int, input().split()))
	b2.sort()
	arr.sort()
	ans = 0
	ct = 0
	i = 0
	while b2 and ct < k and (i < n):
		if b2[-1] > arr[i]:
			val = b2.pop()
			arr[i] = val
			ct += 1
		i += 1
	print(sum(arr))


from collections import *
from bisect import *
from math import *
import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	s = 0
	(i, j) = (0, 0)
	while i < n and j < n:
		if a[i] > b[i]:
			s += a[i]
			i += 1
		elif k:
			k -= 1
			s += b[j]
			j += 1
			i += 1
		else:
			s += a[i]
			i += 1
	print(s)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		if min(a) < max(b):
			b.append(min(a))
			a.remove(min(a))
			a.append(max(b))
			b.remove(max(b))
	print(sum(a))


n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while y > 0:
		y -= 1
		mn = min(a)
		mx = max(b)
		if mx > mn:
			a.remove(mn)
			a.append(mx)
			b.remove(mx)
		else:
			break
	print(sum(a))


def solve(n, k, a, b):
	a = sorted(a)
	b = sorted(b, reverse=1)
	for i in range(k):
		for j in range(i, k):
			if b[j] > a[i]:
				temp = a[i]
				a[i] = b[j]
				b[j] = temp
			break
	print(sum(a))
	return
t = int(input().strip())
n = []
for _ in range(t):
	nm = input().split()
	n = int(nm[0])
	k = int(nm[1])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(n, k, a, b)


import random
import math
import sys
LI = lambda : list(map(int, input().split()))
MI = lambda : map(int, input().split())
yes = lambda : print('Yes')
no = lambda : print('No')
I = lambda : list(input())
J = lambda x: ''.join(x)
II = lambda : int(input())
SI = lambda : input()
t = II()
for q in range(t):
	(n, k) = MI()
	a = sorted(LI())
	b = sorted(LI())[:][::-1]
	s = sum(a)
	for i in range(n):
		if k == 0:
			break
		if b[i] > a[i]:
			(a[i], b[i]) = (b[i], a[i])
			s -= b[i]
			s += a[i]
			k -= 1
		else:
			break
	print(s)


for _ in range(0, int(input())):
	(n, k) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	a.sort()
	b.sort()
	b.reverse()
	for i in range(0, k):
		if b[0] > a[0]:
			(b[0], a[0]) = (a[0], b[0])
			a.sort()
			b.pop(0)
			b.sort()
			b.reverse()
		else:
			break
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	al = list(map(int, input().split()))
	bl = list(map(int, input().split()))
	al.sort()
	bl.sort()
	bl = bl[::-1]
	su = 0
	aln = al[0:k] + bl[0:k]
	aln.sort()
	aln = aln[::-1]
	for i in range(k):
		su += aln[i]
	al2 = al[k:]
	su += sum(al2)
	print(su)


def solve(n, k, a, b):
	i = 0
	while i < k:
		ai = a.index(min(a))
		bi = b.index(max(b))
		if a[ai] < b[bi]:
			(a[ai], b[bi]) = (b[bi], a[ai])
		i += 1
	return sum(a)

def main():
	t = int(input())
	rest = []
	for _ in range(t):
		(n, k) = input().split(' ')
		a = input()
		b = input()
		(N, K) = (int(n), int(k))
		A = [int(i) for i in a.split(' ')]
		B = [int(i) for i in b.split(' ')]
		rest.append(solve(N, K, A, B))
	for i in rest:
		print(i)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	c = 0
	while c < k:
		if b[c] <= a[c]:
			break
		else:
			a[c] = b[c]
		c += 1
	print(sum(a))


for i in range(int(input())):
	(n, k) = (int(i) for i in input().split())
	(a, b) = (sorted((int(i) for i in input().split())), sorted((int(i) for i in input().split())))
	for i in range(k):
		if a[i] < b[-i - 1]:
			a[i] = b[-i - 1]
		else:
			break
	print(sum(a))


def main():
	t = int(input())
	for i in range(t):
		(n, k) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a.sort()
		b.sort(reverse=True)
		total = 0
		for (index, element) in enumerate(a):
			if index < k and b[index] > a[index]:
				total += b[index]
			else:
				total += a[index]
		print(total)
main()


t = int(input().strip())
for i in range(t):
	(n, k) = list(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	posa = 0
	posb = 0
	for j in range(k):
		if max(b) > min(a):
			posb = b.index(max(b))
			posa = a.index(min(a))
			(a[posa], b[posb]) = (b[posb], a[posa])
		else:
			break
	print(sum(a))


test = int(input())
while test != 0:
	(n, k) = [int(x) for x in input().split()]
	a = list([int(x) for x in input().split()])
	b = list([int(x) for x in input().split()])
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	while k != 0:
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			i += 1
			j -= 1
			k -= 1
		else:
			break
	print(sum(a))
	test -= 1


T = int(input())
for t in range(T):
	(N, K) = map(int, input().split())
	A = sorted(list(map(int, input().split())))
	B = sorted(list(map(int, input().split())), reverse=True)
	for k in range(K):
		if A[k] >= B[k]:
			break
		(A[k], B[k]) = (B[k], A[k])
	print(sum(A))


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
from heapq import heappush as pus, heappop as pp, heapify
for _ in range(int(input())):
	(n, k) = mapi()
	a = list(mapi())
	b = list(mapi())
	b = [-i for i in b]
	heapify(a)
	heapify(b)
	while k > 0:
		x = pp(a)
		y = abs(pp(b))
		if x >= y:
			pus(a, x)
			break
		pus(b, -x)
		pus(a, y)
		k -= 1
	print(sum(a))


test = int(input())
for i in range(test):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	if k == 0:
		print(sum(a))
	else:
		a.sort()
		b.sort(reverse=True)
		for i in range(k):
			if a[i] < b[i]:
				a[i] = b[i]
		print(sum(a))


W = int(input())
for i in range(W):
	X = input()
	for E in range(len(X)):
		u = X[E]
		if u == ' ':
			n = int(X[0:E])
			m = int(X[E + 1:-1] + X[-1])
	N = input()
	M = input()
	q = 0
	A = N.split()
	B = M.split()
	for Y in range(n):
		A[Y] = int(A[Y])
		B[Y] = int(B[Y])
	A.sort()
	B.sort()
	L = 0
	while L < m and A[L] < B[n - L - 1]:
		A[L] = B[n - L - 1]
		L += 1
	b = 0
	for p in range(n):
		b += A[p]
	print(b)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = sorted(a)
	b = sorted(b, reverse=True)
	for i in range(k):
		a[i] = max(a[i], b[i])
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))[::-1]
	b = sorted(list(map(int, input().split())))[::-1]
	mx = 0
	for p in range(k + 1):
		z = a[0:n - p] + b[0:p]
		if sum(z) > mx:
			mx = sum(z)
	print(mx)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	i = 0
	f = 0
	while i < n and f == 0 and (i < k):
		if a[i] < b[i]:
			x = a[i]
			a[i] = b[i]
			b[i] = x
		i = i + 1
	print(sum(a))


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	a.sort()
	b.sort(reverse=True)
	for i in range(n):
		l.append(max(a[i], b[i]))
	sum = 0
	for i in range(k):
		sum += l[i]
	for i in range(k, n):
		sum += a[i]
	print(sum)


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr.sort()
	brr.sort(reverse=True)
	i = 0
	j = 0
	while k > 0 and i < n and (j < n):
		if arr[i] < brr[j]:
			arr[i] = brr[j]
			i += 1
		j += 1
		k -= 1
	print(sum(arr))


t = int(input())
while t:
	t -= 1
	(n, k) = input().split(' ')
	(n, k) = (int(n), int(k))
	a = input().split(' ')
	for i in range(n):
		a[i] = int(a[i])
	b = input().split(' ')
	for i in range(n):
		b[i] = int(b[i])
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	while a[i] <= b[j]:
		if k == 0:
			break
		(a[i], b[j]) = (b[j], a[i])
		j -= 1
		i += 1
		k -= 1
		if k == 0:
			break
	print(sum(a))


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline().split()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
test = int_input()
for _ in range(test):
	(n, k) = multi_int_input()
	a = list_input()
	b = list_input()
	a.sort()
	b.sort(reverse=True)
	ptr = 0
	while k > 0:
		if a[ptr] < b[ptr]:
			a[ptr] = b[ptr]
			ptr += 1
			k -= 1
		else:
			break
	print(sum(a))


T = int(input())
for i in range(T):
	ip = input().split()
	n = int(ip[0])
	k = int(ip[1])
	a = input().split()
	b = input().split()
	for j in range(len(a)):
		a[j] = int(a[j])
		b[j] = int(b[j])
	for p in range(k):
		if min(a) < max(b):
			t = a[a.index(min(a))]
			a[a.index(min(a))] = b[b.index(max(b))]
			b[b.index(max(b))] = t
	sum = 0
	for q in a:
		sum += q
	print(sum)


t = int(input())
result = []
for i in range(t):
	string = input().split()
	n = int(string[0])
	k = int(string[1])
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	res = 0
	results = [sum(a)]
	for q in range(k):
		f = b[q]
		b[q] = a[q]
		a[q] = f
		results.append(sum(a))
	result.append(max(results))
for i in result:
	print(i)


import sys
from collections import defaultdict
import random
import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	sum = 0
	c = 0
	for i in range(k):
		if a[i] < b[i]:
			sum += b[i]
			c += 1
	for i in range(c, n):
		sum += a[i]
	print(sum)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	s = 0
	for j in range(n - k):
		s = s + a[j]
	p = n - k
	q = 0
	r = n - k
	while r < n:
		if a[p] >= b[q]:
			s = s + a[p]
			p = p + 1
		else:
			s = s + b[q]
			q = q + 1
		r = r + 1
	print(s)


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	sm = sum(a)
	mx = sm
	for i in range(k):
		(a[i], b[i]) = (b[i], a[i])
		if sum(a) > mx:
			mx = sum(a)
	print(mx)


t = int(input(''))
for i in range(t):
	(n, k) = list(map(int, input('').split(' ')))
	a = list(map(int, input('').split(' ')))
	a.sort()
	b = list(map(int, input('').split(' ')))
	b.sort()
	b.reverse()
	for i in range(k):
		for j in range(len(b)):
			if a[i] < b[i]:
				(a[i], b[i]) = (b[i], a[i])
				break
	print(sum(a))


t = int(input())
for tc in range(t):
	(n, k) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:n]
	a = sorted(a)
	b = sorted(b, reverse=True)
	for i in range(0, n):
		if a[i] < b[i] and k > 0:
			a[i] = b[i]
			k = k - 1
	print(sum(a))


for _ in [0] * int(input()):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()))[::-1]
	i = 0
	while k and a[i] < b[i]:
		a[i] = b[i]
		i += 1
		k -= 1
	print(sum(a))


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(x) for x in input().split()])
	i = 0
	j = n - 1
	count = 0
	while count < k and i < n:
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			i += 1
			j -= 1
			count += 1
		else:
			break
	print(sum(a))


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(x) for x in input().split()], reverse=True)
	j = 0
	for i in range(n):
		if k == 0:
			break
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			j += 1
			k -= 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().strip().split())
	arr1 = list(map(int, input().strip().split()))
	arr2 = list(map(int, input().strip().split()))
	arr1 = sorted(arr1)
	arr2 = sorted(arr2, reverse=True)
	i = 0
	while k != 0:
		if arr1[i] < arr2[i]:
			(arr1[i], arr2[i]) = (arr2[i], arr1[i])
			k -= 1
		else:
			break
		i += 1
	print(sum(arr1))


import sys

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

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
i = int(input())
for j in range(i):
	(n, k) = get_ints()
	ar1 = get_list()
	ar2 = sorted(get_list(), reverse=True)
	for j in range(k):
		if ar2[0] > min(ar1):
			ar1.remove(min(ar1))
			ar1.append(ar2.pop(0))
	print(sum(ar1))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	s = 0
	cn = 0
	for i in range(n):
		if a[i] < b[i] and cn < k:
			s += b[i]
			cn += 1
		elif a[i] >= b[i] and cn < k:
			s += a[i]
		elif cn >= k:
			s += a[i]
	print(s)
	t -= 1


T = int(input())
for test in range(T):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	for i in range(k):
		if l1[i] < l2[n - i - 1]:
			l1[i] = l2[n - i - 1]
		else:
			break
	s = 0
	for el in l1:
		s += el
	print(s)


ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda : int(input())
ip = lambda : [int(w) for w in input().split()]
for _ in range(inp()):
	(n, k) = ip()
	a = ip()
	b = ip()
	b.sort(reverse=True)
	a.extend(b[:k])
	a.sort(reverse=True)
	print(sum(a[:n]))


test_case = int(input())
for i in range(test_case):
	values = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	for i in range(values[1]):
		if a[a.index(min(a))] < b[b.index(max(b))]:
			(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
	print(sum(a))


t = int(input())
for i in range(t):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(m):
		if b[i] > a[i]:
			a[i] = b[i]
		else:
			continue
	print(sum(a))


def answer():
	n = int(input())
	potato = n
	c_out = []
	while n:
		s = input().split()
		s = [int(x) for x in s]
		n2 = s[0]
		k = s[1]
		a = input().split()
		a = [int(x) for x in a]
		b = input().split()
		b = [int(x) for x in b]
		while k:
			rem = min(a)
			op = max(b)
			if rem < op:
				b.append(rem)
				a.remove(rem)
				a.append(op)
				b.remove(op)
			k -= 1
		c_out.append(sum(a))
		n -= 1
	i = 0
	while i < potato:
		print(c_out[i])
		i += 1
answer()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = list(reversed(sorted(list(map(int, input().split())))))
	c = sum(a)
	for (i, x) in zip(a[:k], b[:k]):
		if i < x:
			c += x - i
	print(c)


test = int(input())
while test:
	(n, k) = map(int, input().split())
	nums1 = list(map(int, input().split()))
	nums2 = list(map(int, input().split()))
	while k:
		if max(nums2) <= min(nums1):
			break
		elif n == 1:
			nums1 = max(nums1, nums2)
			break
		else:
			i1 = min(nums1)
			i2 = max(nums2)
			(nums1[nums1.index(i1)], nums2[nums2.index(i2)]) = (nums2[nums2.index(i2)], nums1[nums1.index(i1)])
			k -= 1
	print(sum(nums1))
	test -= 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	while min(l) < max(p) and k > 0:
		mi = min(l)
		ml = l.index(mi)
		mx = max(p)
		mxl = p.index(mx)
		t = l[ml]
		l[ml] = p[mxl]
		p[mxl] = t
		k -= 1
	print(sum(l))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(_) for _ in input().split()]
	b = [int(_) for _ in input().split()]
	for i in range(k):
		if min(a) > max(b):
			break
		else:
			s = a.index(min(a))
			a[s] = max(b)
			b.remove(max(b))
	print(sum(a))


i = input
for a in [0] * int(i()):
	(c, x) = map(int, input().split())
	l1 = list(map(int, i().split()))
	l2 = list(map(int, i().split()))
	for v in range(x):
		l1.append(max(l2))
		l1.remove(min(l1))
		l2.remove(max(l2))
	print(sum(l1))


import heapq as pq

def solve():
	(n, k) = list(map(int, input().split(' ')))
	arr1 = list(map(int, input().split(' ')))
	arr2 = list(map(int, input().split(' ')))
	if k > n:
		k = n
	sm = sum(arr1)
	pq.heapify(arr1)
	arr2 = [-i for i in arr2]
	pq.heapify(arr2)
	while k:
		k -= 1
		if -arr2[0] > arr1[0]:
			sm += -arr2[0] - arr1[0]
			pq.heappop(arr2)
			pq.heappop(arr1)
		else:
			break
	print(sm)
T = int(input())
for i in range(T):
	solve()


for t in range(int(input())):
	(n, k) = (int(x) for x in input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	(aptr, bptr) = (0, 0)
	swaps = 0
	while swaps < k:
		if aptr >= n or bptr >= n:
			break
		if a[aptr] < b[bptr]:
			swaps += 1
			(a[aptr], b[bptr]) = (b[bptr], a[aptr])
		aptr += 1
		bptr += 1
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = n - 1
	j = n - 1
	v = k
	ans = 0
	h = 0
	while k > 0 and i > -1 and (j > -1):
		if a[i] >= b[j]:
			i -= 1
		else:
			(b[j], a[h]) = (a[h], b[j])
			h += 1
			j -= 1
			k -= 1
	print(sum(a))


t = int(input())
while t > 0:
	(n, k) = input().split()
	a = []
	b = []
	x = input()
	y = input()
	for i in range(int(n)):
		a = [int(i) for i in x.split(' ')]
	for i in range(int(n)):
		b = [int(i) for i in y.split(' ')]
	a.sort()
	b.sort(reverse=True)
	for i in range(int(k)):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))
	t = t - 1


from __future__ import division, print_function
import sys
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	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
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	z = inin()
	for i in range(z):
		l = ain()
		n = l[0]
		k = l[1]
		flag = 0
		a = ain()
		b = ain()
		count1 = sum(a)
		a.sort()
		b.sort(reverse=True)
		for j in range(k):
			if a[j] > b[j]:
				print(count1)
				flag = 1
				break
			count1 += b[j] - a[j]
		if flag == 0:
			print(count1)
		count1 = 0
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = []
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	if a[-1] >= b[0]:
		print(sum(a))
	else:
		while a[-1] < b[0] and k > 0:
			b.append(a[-1])
			a.remove(a[-1])
			a.append(b[0])
			b.remove(b[0])
			a.sort(reverse=True)
			b.sort(reverse=True)
			k = k - 1
		print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	s = sum(a)
	p = [s]
	for i in range(k):
		s -= a[i]
		s += b[i]
		p.append(s)
	print(max(p))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	aa = sorted(a)
	bb = sorted(b)[::-1]
	i = 0
	s = 0
	l = []
	while k > 0 and i < n:
		if aa[i] < bb[i]:
			k = k - 1
			l.append(i)
			s = s + bb[i]
		i = i + 1
	for i in range(n):
		if i not in l:
			s = s + aa[i]
	print(s)


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	lows = []
	for i in range(k):
		lows.append(min(a))
		a.remove(min(a))
	highs = []
	for i in range(k):
		highs.append(max(b))
		b.remove(max(b))
	final = []
	for i in range(len(lows)):
		if lows[i] < highs[i]:
			final.append(highs[i])
		else:
			final.append(lows[i])
	print(sum(a) + sum(final))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(m):
		if a[i] < b[0]:
			a[i] = b[0]
			b.pop(0)
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k:
		k -= 1
		a.sort()
		b.sort()
		if b[-1] <= a[0]:
			break
		else:
			(b[-1], a[0]) = (a[0], b[-1])
	s = 0
	for i in range(len(a)):
		s += a[i]
	print(s)


size = int(input())
for i in range(size):
	(arr_size, swap) = input().split(' ')
	arr_size = int(arr_size)
	swap = int(swap)
	temp = 0
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	suming = 0
	for i in range(swap):
		if a[i] < b[i]:
			temp = b[i]
			b[i] = a[i]
			a[i] = temp
	for i in range(len(a)):
		suming += a[i]
	a.clear()
	b.clear()
	print(suming)


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	q = sum(a)
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	l1 = []
	for ii in range(k):
		(a[ii], b[ii]) = (b[ii], a[ii])
		c = sum(a)
		l1.append(c)
	if len(l1) != 0:
		s = max(l1)
		print(max(q, s))
	else:
		print(q)


def ninja(a, b, k):
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	while k > 0 and i < n and (j >= 0):
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
		i += 1
		j -= 1
		k -= 1
	return sum(a)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(ninja(a, b, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	summ = sum(a)
	a.sort()
	b.sort()
	if k == 0:
		print(sum(a))
	else:
		i = 0
		while i < k and a[i] < b[n - i - 1]:
			(a[i], b[n - i - 1]) = (b[n - i - 1], a[i])
			i += 1
		print(sum(a))


from sys import stdin, stdout

def solve():
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	if k == 0:
		return sum(a)
	a.sort()
	b.sort(reverse=True)
	sa = sum(a)
	for i in range(min(k, n)):
		if b[i] > a[i]:
			sa += b[i] - a[i]
		else:
			break
	return sa
for _ in range(int(stdin.readline())):
	stdout.write(str(solve()) + '\n')


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = sum(a)
	s = 0
	e = n - 1
	for i in range(k):
		if a[s] < b[e]:
			ans += b[e] - a[s]
			s += 1
			e -= 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase

def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(n):
		if a[i] < b[i] and k > 0:
			a[i] = b[i]
			k = k - 1
	return sum(a)

def main():
	for _ in range(int(input())):
		print(solve())
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()


for i in range(int(input())):
	l = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(l[1]):
		if min(a) < max(b):
			a.remove(min(a))
			a.append(max(b))
			b.remove(max(b))
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sumA = sum(a)
	a.sort()
	b.sort()
	for i in range(k):
		temp = sumA - a[i] + abs(b[n - 1 - i])
		if temp > sumA:
			sumA = temp
	print(sumA)


import sys

def solve():
	(n, m) = map(int, sys.stdin.readline().split())
	a = input()
	a = list(map(int, a.split(' ')))
	b = input()
	b = list(map(int, b.split(' ')))
	a.sort()
	b.sort(reverse=1)
	for x in range(0, m):
		if a[x] < b[x]:
			(a[x], b[x]) = (b[x], a[x])
	ans = 0
	for x in a:
		ans = ans + x
	print(ans)
t = int(input())
while t:
	solve()
	t = t - 1


def sumarr(a, n):
	r = 0
	for i in range(n):
		r += a[i]
	return r
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	sums = sum(a)
	maxs = sums
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	while k:
		temp = b[n - 1]
		b[n - 1] = a[0]
		a[0] = temp
		a.sort()
		b.sort()
		sums = sumarr(a, n)
		if sums > maxs:
			maxs = sums
		k -= 1
	print(maxs)


casos = int(input())
for _ in range(casos):
	(a, b) = map(int, input().split())
	array_a = list(map(int, input().split()))
	array_b = list(map(int, input().split()))
	array_a.sort()
	array_b.sort(reverse=True)
	k = 0
	for i in range(b):
		if array_a[i] < array_b[k]:
			temp = array_a[i]
			array_a[i] = array_b[i]
			array_b[i] = temp
			k += 1
	print(sum(array_a))


T = int(input())
answers = []
for _ in range(T):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	sum_max = sum(a)
	for _ in range(k):
		if sum_max < sum(a):
			break
		a_i = a.index(min(a))
		b_i = b.index(max(b))
		if max(b) <= min(a):
			break
		(a[a_i], b[b_i]) = (b[b_i], a[a_i])
		if sum(a) > sum_max:
			sum_max = sum(a)
	answers.append(sum_max)
for a in answers:
	print(a)


import sys
import math
from collections import deque
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(n - 1, max(-1, n - 1 - k), -1):
		if b[i] > a[n - i - 1]:
			a[n - i - 1] = b[i]
	print(sum(a))


case = int(input())
for i in range(case):
	(n, k) = (int(v) for v in input().split())
	list1 = [int(u) for u in input().split()]
	list2 = [int(w) for w in input().split()]
	list2.sort(reverse=True)
	for j in range(k):
		if list2[j] > min(list1):
			list1.remove(min(list1))
			list1.append(list2[j])
		else:
			break
	print(sum(list1))


I = lambda : list(map(int, input().split()))
t = I()[0]
while t:
	t -= 1
	(n, k) = I()
	(a, b) = (I(), I())
	a.sort()
	b.sort(reverse=True)
	i = 0
	while k:
		if a[i] >= b[i]:
			break
		(a[i], b[i]) = (b[i], a[i])
		k -= 1
		i += 1
	print(sum(a))


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
import bisect as bi
import heapq

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

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

def L():
	return list(In())

def main():
	try:
		(n, m) = In()
		a = list(In())
		b = list(In())
		a.sort()
		b.sort(reverse=True)
		for i in range(m):
			if b[i] > a[i]:
				(b[i], a[i]) = (a[i], b[i])
		print(sum(a))
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	q = list(map(int, input().split()))
	p.sort()
	q.sort(reverse=True)
	s = 0
	ka = 0
	f = 0
	i = 0
	for i in range(k):
		if p[i] < q[i]:
			s += q[i]
		else:
			ka = i
			f = 1
			break
	if f == 0:
		if i == 0 and s == 0:
			ka = 0
		else:
			ka = i + 1
	for j in range(ka, n):
		s += p[j]
	print(s)


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	arr.sort()
	arr1.sort(reverse=True)
	k = 0
	while b > 0:
		if arr[k] < arr1[k]:
			arr[k] = arr1[k]
		k += 1
		b -= 1
	ans = sum(arr)
	print(ans)


def mn(a):
	ind = 0
	for i in range(len(a)):
		if a[i] < a[ind]:
			ind = i
	return ind

def mx(a):
	ind = 0
	for i in range(len(a)):
		if a[i] > a[ind]:
			ind = i
	return ind
ans = []
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for g in range(k):
		if a[mn(a)] >= b[mx(b)]:
			break
		else:
			(a[mn(a)], b[mx(b)]) = (b[mx(b)], a[mn(a)])
	ans += [sum(a)]
for i in ans:
	print(i)


def f():
	s = input().split(' ')
	n = int(s[0])
	k = int(s[1])
	a = input().split(' ')
	b = input().split(' ')
	for i in range(n):
		a[i] = int(a[i])
		b[i] = int(b[i])
	a = sorted(a)
	b = sorted(b)
	for i in range(k):
		if a[i] < b[n - 1 - i]:
			a[i] = b[n - 1 - i]
	print(sum(a))
t = int(input())
for i in range(t):
	f()


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = sum(a)
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] >= a[i]:
			ans += b[i] - a[i]
		else:
			break
	print(ans)
	t -= 1


def read_int():
	n = int(input())
	return n

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def solve(n, k, a, b):
	while k > 0:
		amin = min(a)
		bmax = max(b)
		if bmax <= amin:
			break
		i = a.index(amin)
		j = b.index(bmax)
		(a[i], b[j]) = (b[j], a[i])
		k -= 1
	return sum(a)
t = read_int()
for case in range(t):
	(n, k) = read_ints()
	a = read_ints()
	b = read_ints()
	sol = solve(n, k, a, b)
	print(sol)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	asor = sorted(a)
	bsor = sorted(b, reverse=True)
	for i in range(k):
		if asor[i] < bsor[i]:
			asor[i] = bsor[i]
		else:
			break
	print(sum(asor))


for i in range(int(input())):
	(p, q) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(q):
		c = min(a)
		d = max(b)
		if c < d:
			m = a.index(c)
			n = b.index(d)
			a[m] = d
			b[n] = c
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k > 0:
		if min(a) < max(b):
			a.remove(min(a))
			a.append(max(b))
			b.remove(max(b))
		else:
			break
		k = k - 1
	print(sum(a))


def solve(n, k, a, b):
	a = sorted(a)
	swap = 0
	j = 0
	sum = 0
	while swap < k and j < n:
		b = sorted(b)
		if a[j] < b[n - 1]:
			(a[j], b[n - 1]) = (b[n - 1], a[j])
			swap += 1
		else:
			break
		j += 1
	for i in a:
		sum += i
	print(sum)
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(n, k, a, b)


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	for i in range(n):
		l.append((a[i], 0))
		l.append((b[i], 1))
	l.sort(reverse=True)
	p = 1
	ans = 0
	q = 0
	for i in range(len(l)):
		if p <= k:
			ans += l[i][0]
			q += 1
			if l[i][1] == 1:
				p += 1
		elif l[i][1] == 0:
			ans += l[i][0]
			q += 1
		if q == n:
			break
	print(ans)


for x in range(int(input())):
	(a, b) = map(int, input().split())
	q = list(map(int, input().split()))
	w = list(map(int, input().split()))
	while b:
		c = min(q)
		d = max(w)
		if c >= d:
			break
		else:
			q.append(d)
			q.remove(c)
			w.append(c)
			w.remove(d)
		b -= 1
	print(sum(q))


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort(reverse=True)
	b.sort(reverse=True)
	i = 0
	j = 0
	sumTotal = 0
	n = int(n)
	while n > 0:
		if a[i] < b[j] and j < int(k):
			sumTotal += b[j]
			j += 1
		else:
			sumTotal += a[i]
			i += 1
		n -= 1
	print(sumTotal)


def main():
	N = int(input())
	for _ in range(N):
		(n, k) = map(int, input().split())
		A = list(map(int, input().split()))
		B = list(map(int, input().split()))
		A.sort()
		B.sort(reverse=True)
		ans = 0
		for i in range(n):
			if i + 1 <= k:
				if A[i] < B[i]:
					ans += B[i]
					continue
			ans += A[i]
		print(ans)
main()


from math import inf

def merge(T, p, q, r):
	L = T[p:q + 1]
	R = T[q + 1:r + 1]
	L.append(inf)
	R.append(inf)
	i = j = 0
	for k in range(p, r + 1):
		if L[i] <= R[j]:
			T[k] = L[i]
			i += 1
		else:
			T[k] = R[j]
			j += 1

def merge_sort(T, p, r):
	if len(T) == 1 or len(T) < 1:
		return T
	if p < r:
		m = (p + r) // 2
		merge_sort(T, p, m)
		merge_sort(T, m + 1, r)
		merge(T, p, m, r)
	return T
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_sort = merge_sort(a, 0, len(a) - 1)
	b_sort = merge_sort(b, 0, len(b) - 1)
	result = 0
	for i in range(len(a_sort)):
		if a_sort[i] < b_sort[-1 - i] and i < k:
			a_sort[i] = b_sort[-1 - i]
		result += a_sort[i]
	print(result)


n = int(input())
(A, B, X) = ([], [], [])
for i in range(n):
	x = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	X.append(x)
	A.append(a)
	B.append(b)

def swap(x, a, b):
	a.sort()
	b.sort()
	for i in range(x[1]):
		if a[i] < b[-(i + 1)]:
			(a[i], b[-(i + 1)]) = (b[-(i + 1)], a[i])
	return sum(a)
for i in range(n):
	print(swap(X[i], A[i], B[i]))


def solution():
	(n, k) = map(lambda x: int(x), input().split())
	a = sorted(list(map(lambda x: int(x), input().split())))
	b = sorted(list(map(lambda x: int(x), input().split())), reverse=True)
	(l, r) = (0, 0)
	while k > 0 and r < n and (l < n):
		if a[l] < b[r]:
			c = a[l]
			a[l] = b[r]
			b[r] = c
			k -= 1
			l += 1
			r += 1
			continue
		while r < n and a[l] >= b[r]:
			r += 1
	print(sum(a))
t = int(input())
for _ in range(t):
	solution()


T = int(input())
n = [0] * T
m = [0] * T
a = [0] * T
b = [0] * T
for t in range(T):
	(n, k) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[n - i - 1]:
			a[i] = b[n - i - 1]
		else:
			break
	print(sum(a))


def solve(a: list, b: list, k):
	a.sort()
	b.sort()
	n = len(a)
	i = 0
	j = n - 1
	cnt = 0
	while i <= n - 1 and j >= 0 and (k > 0):
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			cnt += 1
			j -= 1
			i += 1
			k -= 1
		else:
			break
	return sum(a)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(a, b, k))


T = int(input())
for i in range(0, T):
	(n, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	ans = 0
	ctr = 0
	for j in range(0, k):
		if A[j] < B[n - j - 1]:
			ans += B[n - j - 1]
			ctr += 1
		else:
			break
	for j in range(ctr, n):
		ans += A[j]
	print(ans)


def r(t=int):
	return list(map(t, input().split()))

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

def cd(it):
	ret_val = dict()
	for v in it:
		ret_val[v] = ret_val.get(v, 0) + 1
	return ret_val
for _ in range(ri()):
	(n, k) = r()
	a = r()
	b = r()
	a.sort()
	b.sort(reverse=True)
	ans = 0
	for (ai, bi) in zip(a, b):
		k -= 1
		if k >= 0:
			ans += max(ai, bi)
		else:
			ans += ai
	print(ans)


import sys
import math
data = sys.stdin.readlines()
for i in range(int(data[0])):
	nk = list(map(int, data[i * 3 + 1].split(' ')))
	a = list(map(int, data[i * 3 + 2].split(' ')))
	b = list(map(int, data[i * 3 + 3].split(' ')))
	n = nk[0]
	k = nk[1]
	a.sort()
	b.sort(reverse=True)
	c = a[:k] + b[:k]
	c.sort(reverse=True)
	print(sum(c[:k]) + sum(a[k:]))


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		A = list(map(int, input().split()))
		B = list(map(int, input().split()))
		A.sort()
		B.sort()
		ans = sum(A)
		for i in range(k):
			a = A[i]
			b = B[-i - 1]
			if a < b:
				ans -= a
				ans += b
		sys.stdout.write(str(ans) + '\n')
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	suma = sum(a)
	sumb = sum(b)
	c = 0
	a = sorted(a)
	b = sorted(b)
	while c < k:
		amin = min(a)
		bmax = max(b)
		if amin >= bmax:
			break
		else:
			suma = suma - amin + bmax
			sumb = sumb - bmax + amin
			apop = a.pop(0)
			bpop = b.pop(-1)
		c += 1
	print(suma)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	b = list(map(int, input().split()))
	b.sort()
	summ = sum(a[k:])
	c = a[:k] + b[len(b) - k:]
	c.sort()
	summ += sum(c[len(c) - k:])
	print(summ)


t = int(input())
for _ in range(t):
	(n, k) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	max_sum = 0
	i = 0
	while i < k:
		if a[i] < b[i]:
			max_sum += b[i]
		else:
			break
		i += 1
	max_sum += sum(a[i:])
	print(max_sum)


t = int(input())
for q in range(t):
	s = [int(i) for i in input().split()]
	n = s[0]
	k = s[1]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a = sorted(a)
	b = sorted(b, reverse=True)
	for j in range(k):
		if a[j] < b[j]:
			temp = a[j]
			a[j] = b[j]
			b[j] = temp
		else:
			break
	print(sum(a))


from sys import stdin
input = stdin.readline

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

def sep_input():
	return map(int, input().split())
for _ in range(int(input())):
	(n, k) = sep_input()
	a = list_input()
	b = list_input()
	if k == 0:
		print(sum(a))
	else:
		a.sort()
		b.sort(reverse=True)
		i = 0
		j = 0
		while i < n and j < n and (k > 0):
			if a[i] < b[j]:
				temp = a[i]
				a[i] = b[i]
				b[i] = temp
				i += 1
				j += 1
				k -= 1
			else:
				break
		print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b = sorted(b)
	if k == 0:
		l = a
	else:
		l = a + b[-k:]
	l = sorted(l)
	print(sum(l[-n:]))


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	h = 1
	summ = sum(a)
	while h <= k:
		if a[i] >= b[-i - 1]:
			break
		summ += b[-i - 1] - a[i]
		i += 1
		h += 1
	print(summ)


n = int(input())
for i in range(n):
	(r, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	b = list(map(int, input().split()))
	b.sort()
	for i in range(m):
		if b[-1] > a[0]:
			(b[-1], a[0]) = (a[0], b[-1])
			a.sort()
			b.sort()
		else:
			break
	k = 0
	for i in a:
		k = k + i
	print(k)


def function(n, k, a, b):
	b.sort()
	if k == 0:
		print(sum(a))
	else:
		a = a + b[n - k:n]
		a.sort()
		print(sum(a[k:]))
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	function(n, k, a, b)


t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	tot = 0
	for i in range(0, n):
		the = 0
		for j in range(1, n):
			if b[j] > a[i] and b[the] < b[j]:
				the = j
		if b[the] > a[i] and tot < k:
			aaa = a[i]
			a[i] = b[the]
			b[the] = aaa
			tot += 1
		if tot >= k:
			break
	ct = 0
	for x in a:
		ct += x
	print(ct)
	t -= 1


n = int(input())
for _ in range(n):
	(n1, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b = sorted(b, reverse=True)
	for i in range(n1):
		if b[i] > min(a) and k > 0:
			k -= 1
			a.remove(min(a))
			a.append(b[i])
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	b = sorted(list(map(int, input().split())))
	c = sorted(list(map(int, input().split())), reverse=True)
	j = 0
	while j < k:
		if b[j] < c[j]:
			b[j] = c[j]
		else:
			break
		j += 1
	print(sum(b))


n = int(input())

def calc(a, b, y):
	c = sum(a)
	for i in range(y):
		if min(a) < max(b):
			c = c - min(a)
			c = c + max(b)
			a.remove(min(a))
			b.remove(max(b))
	print(c)
for i in range(n):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	calc(a, b, y)


t = int(input())
solution_list = []
arrays = []
for i in range(t):
	z = [int(x) for x in input().split(' ')]
	k = z[1]
	x = [int(x) for x in input().split(' ')]
	y = [int(x) for x in input().split(' ')]
	x_sorted = sorted(x)
	y_sorted = sorted(y, reverse=True)
	if x_sorted == y_sorted:
		x_sorted = x_sorted
	else:
		a = 0
		b = 0
		for a in range(k):
			if x_sorted[a] < y_sorted[b]:
				x_sorted[a] = y_sorted[b]
				b = b + 1
				a = a + 1
			else:
				x_sorted[a] = x_sorted[a]
	solution_list.append(sum(x_sorted))
for i in solution_list:
	print(i)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	for j in range(min(k, len(a))):
		if b[j] > a[j]:
			a[j] = b[j]
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	if k == 0 or min(arr) >= max(brr):
		print(sum(arr))
		continue
	arr.sort()
	p = sum(arr)
	brr = sorted(brr, reverse=True)
	for i in range(k):
		if arr[i] >= brr[i]:
			break
		else:
			p = p - arr[i] + brr[i]
	print(p)


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = sum(a)
	a.sort()
	b.sort()
	b.reverse()
	idx = 0
	while idx < k and idx < n and (a[idx] < b[idx]):
		ans += b[idx] - a[idx]
		idx += 1
	print(ans)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
a = list()
b = list()
c = list()
y = t
while y > 0:
	str1 = input()
	d = str1.split()
	n = int(d[0])
	k = int(d[1])
	str2 = input()
	a = str2.split()
	str3 = input()
	b = str3.split()
	x = 0
	while x < n:
		a[x] = int(a[x])
		b[x] = int(b[x])
		x = x + 1
	a.sort()
	b.sort(reverse=True)
	z = k
	w = 0
	r = n - 1
	while z > 0:
		if b[w] > a[w]:
			a[w] = b[w]
			b[w] = 0
			a.sort()
			b.sort(reverse=True)
			r = r - 1
		z = z - 1
	c.append(sum(a))
	a.clear()
	b.clear()
	y = y - 1
for r in c:
	print(r)


testy = int(input(''))
results = []
for i in range(0, testy):
	wejscie = input('')
	k = int(wejscie.split()[1])
	a = input('').split()
	b = input('').split()
	a = list(map(int, a))
	b = list(map(int, b))
	a.sort()
	b.sort()
	for j in range(0, k):
		if b[len(b) - 1 - j] - a[j] > 0:
			a.append(b[len(b) - 1 - j] - a[j])
	results.append(sum(a))
for result in results:
	print(result)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	b1 = []
	b2 = []
	for i in range(n):
		b1.append(b[i])
	for j in range(k):
		if k == 0:
			print(sum(a))
		elif b1[j] > a[0]:
			a.pop(0)
			b2.append(b1[j])
		else:
			pass
	a.extend(b2)
	print(sum(a))


import io, os
R = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, k) = R()
	a = list(R())
	b = list(R())
	a.sort(reverse=True)
	b.sort(reverse=True)
	(i, j) = (0, 0)
	ans = 0
	res = n
	while res and k and (i < n) and (j < n):
		if a[i] > b[j]:
			ans += a[i]
			i += 1
			res -= 1
		else:
			ans += b[j]
			j += 1
			k -= 1
			res -= 1
	while res and i < n:
		ans += a[i]
		i += 1
		res -= 1
	print(ans)


no_of_test_cases = int(input())
for i in range(no_of_test_cases):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		if k == 0:
			break
		else:
			max_b = max(b)
			min_a = min(a)
			if max_b > min_a:
				a.append(max_b)
				a.remove(min_a)
				b.append(min_a)
				b.remove(max_b)
			k -= 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		mini = min(a)
		o = a.index(mini)
		maxi = max(b)
		if mini >= maxi:
			pass
		else:
			a[o] = maxi
			b.remove(maxi)
	print(sum(a))


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l.sort()
	b.sort()
	for e in range(k):
		if l[e] < b[-1]:
			l[e] = b[-1]
			b.remove(b[-1])
		else:
			break
	print(sum(l))


t = int(input())
for v in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort()
	count = 1
	i = 0
	j = n - 1
	while count <= k:
		if a[i] > b[j]:
			break
		else:
			a[i] = b[j]
			i += 1
			j -= 1
		count += 1
	ans = 0
	for i in range(n):
		ans += a[i]
	print(ans)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a1 = sorted(a)
	b1 = sorted(b)
	b1.reverse()
	ans = []
	d = 0
	for i in range(len(a1)):
		if b1[i] > a1[i] and d < k:
			a1[i] = b1[i]
			ans.append(sum(a1))
			d += 1
		else:
			ans.append(sum(a1))
	print(max(ans))


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	(find, sind) = (0, n - 1)
	count = 0
	while count < k:
		if a[find] >= b[sind]:
			break
		a[find] = b[sind]
		count += 1
		find += 1
		sind -= 1
	res = 0
	for num in a:
		res += num
	print(res)


def main():
	t = int(input())
	for i in range(t):
		(n, k) = (int(x) for x in input().split())
		a = [int(x) for x in input().split()]
		b = [int(x) for x in input().split()]
		for j in range(k):
			min_A = min(a)
			max_B = max(b)
			if max_B > min_A:
				a.remove(min_A)
				b.remove(max_B)
				a.append(max_B)
				b.append(min_A)
			else:
				break
		print(sum(a))
main()


t = int(input())
import math
for i in range(t):
	(n, k) = map(int, input().strip().split())
	a = sorted(list(map(int, input().strip().split())))
	b = sorted(list(map(int, input().strip().split())))
	b = b[::-1]
	if k == 0:
		print(sum(a))
		continue
	j = 0
	for i in range(n):
		if b[j] > a[i]:
			(a[i], b[j]) = (b[j], a[i])
			j += 1
			k -= 1
			if k == 0:
				break
	print(sum(a))


T = int(input())
for _ in range(T):
	(n, k) = list(map(int, input().split(' ')))
	arr1 = sorted([int(x) for x in input().split(' ')])
	arr2 = sorted([int(x) for x in input().split(' ')])
	j = n - 1
	ans = i = 0
	while k > 0 and arr2[j] > arr1[i]:
		ans += arr2[j]
		k -= 1
		i += 1
		j -= 1
	while i < n:
		ans += arr1[i]
		i += 1
	print(ans)


for _ in range(int(input())):
	X = list(map(int, input().split()))
	A = sorted(list(map(int, input().split())))
	B = sorted(list(map(int, input().split())), reverse=True)
	SUM = 0
	for i in range(X[1]):
		SUM += max(A[i], B[i])
	print(SUM + sum(A[X[1]:]))


for _ in range(0, int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(0, k):
		if min(a) < max(b):
			j = a.index(min(a))
			k = b.index(max(b))
			temp = a[j]
			a[j] = b[k]
			b[k] = temp
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = input().split(' ')
	(n, k) = (int(n), int(k))
	a = input().split(' ')
	a = [int(i) for i in a]
	b = input().split(' ')
	b = [int(i) for i in b]
	while k:
		a_min = min(a)
		b_max_val = max(b)
		if a_min < b_max_val:
			a[a.index(a_min)] = b_max_val
			b[b.index(b_max_val)] = a_min
		k -= 1
	print(sum(a))


el = int(input())
for i in range(el):
	ar = []
	for i in input().split(' '):
		ar.append(int(i))
	a = []
	for i in input().split(' '):
		a.append(int(i))
	b = []
	for i in input().split(' '):
		b.append(int(i))
	a.sort()
	b.sort(reverse=True)
	k = ar[1]
	while k != 0:
		if a[0] < b[0]:
			temp = a[0]
			a[0] = b[0]
			b[0] = temp
			a.sort()
			b.sort(reverse=True)
			k = k - 1
		else:
			break
	print(sum(a))


tc = int(input())
for testcase in range(tc):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		a[i] = max(a[i], b[i])
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	suma = 0
	sumb = 0
	sum = 0
	for j in range(n):
		sum = sum + a[j]
	ans = sum
	for x in range(k):
		a.sort()
		b.sort()
		suma = suma + a[x]
		sumb = sumb + b[-x - 1]
		ans = max(ans, sum - suma + sumb)
	print(ans)


from sys import *
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	if k == 0:
		print(sum(a))
	else:
		a.sort()
		j = 0
		b.sort(reverse=True)
		for l in range(n):
			if k > 0:
				if a[l] < b[j]:
					a[l] = b[j]
					k = k - 1
					j = j + 1
		print(sum(a))


t = int(input())
arr = [0] * t
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = [0] * n
	b = [0] * n
	a = input().split()
	b = input().split()
	total = 0
	for j in range(n):
		a[j] = int(a[j])
		b[j] = int(b[j])
		total = total + a[j]
	a.sort()
	b.sort()
	for p in range(k):
		if b[n - p - 1] > a[p]:
			total = total - a[p] + b[n - p - 1]
	arr[i] = total
for j in range(t):
	print(arr[j])


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k > 0:
		lowest = min(a)
		idxa = a.index(lowest)
		highest = max(b)
		idxb = b.index(highest)
		if lowest < highest:
			(a[idxa], b[idxb]) = (b[idxb], a[idxa])
		else:
			break
		k -= 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	if k == 0:
		print(sum(a))
	elif k == n:
		s = 0
		for i in range(n):
			s += max(a[i], b[i])
		print(s)
	elif k < n:
		s = 0
		for i in range(k):
			s += max(a[i], b[i])
		for i in range(k, n):
			s += a[i]
		print(s)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		A = min(a)
		B = max(b)
		if A < B:
			a[a.index(A)] = B
			b[b.index(B)] = A
		else:
			break
	print(sum(a))


def sum(x):
	s = 0
	for i in x:
		s += i
	return s
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	if k == 0:
		print(sum(a))
	else:
		a = sorted(a)
		b = sorted(b)
		s = 0
		inc = k
		for i in range(n):
			if inc == 0:
				i_cur = i
				break
			else:
				if a[i] >= b[n - i - 1]:
					s += a[i]
				else:
					s += b[n - i - 1]
				inc -= 1
		if k < n:
			for i in range(i_cur, n):
				s += a[i]
		print(s)


def solve(a, b, k):
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = [int(x) for x in input().split(' ')]
		a = [int(x) for x in input().split(' ')]
		b = [int(x) for x in input().split(' ')]
		solve(a, b, k)
main()


from sys import stdin, stdout

def input():
	return stdin.readline()
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(k) for k in input().split()]
	b = [int(k) for k in input().split()]
	a.sort()
	b.sort(reverse=True)
	for i in range(n):
		if k > 0:
			if a[i] < b[i]:
				a[i] = b[i]
				k -= 1
		else:
			break
	s = sum(a)
	print(s)


t = int(input())
for t1 in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	s = sum(a)
	for o in range(k):
		if a[o] < b[n - 1 - o]:
			s += b[n - 1 - o] - a[o]
		else:
			break
	print(s)


t = int(input(''))
for j in range(t):
	(n, p) = map(int, input('').split(' '))
	a = list(map(int, input(' ').split(' ')))
	b = list(map(int, input(' ').split(' ')))
	a = sorted(a)
	b = sorted(b)
	b.reverse()
	i = 0
	while i < p:
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
			i += 1
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort(reverse=True)
	temp = 0
	for i in range(x):
		if temp != y:
			if arr1[i] < arr2[i]:
				temp += 1
				arr1[i] = arr2[i]
			else:
				break
	print(sum(arr1))


n = int(input())
for i in range(n):
	(l1, l2) = ([], [])
	fla = 0
	(q, w) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	for j in range(w):
		yy = min(l1)
		xx = max(l2)
		if yy > xx:
			print(sum(l1))
			fla = 1
			break
		aa = l1.index(yy)
		bb = l2.index(xx)
		l1[aa] = xx
		l2[bb] = yy
	if fla == 0:
		print(sum(l1))


q = int(input())
for i in range(q):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	for j in range(x):
		if min(a) >= max(b):
			break
		else:
			a.pop(0)
			a.append(b.pop(n - j - 1))
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	a.sort()
	ans = 0
	for i in range(k):
		ans += max(a[i], b[i])
	for i in range(k, n):
		ans += a[i]
	print(ans)


t = int(input())
for j in range(t):
	(length, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 0
	max_list = a.copy()
	min_list = b.copy()
	if k == 0:
		print(sum(a))
		continue
	for j_list in range(k):
		maximum = min(max_list)
		minimum = max(min_list)
		if minimum <= maximum:
			break
		maximum_index = a.index(maximum)
		minimum_index = b.index(minimum)
		(a[maximum_index], b[minimum_index]) = (b[minimum_index], a[maximum_index])
		max_list.remove(maximum)
		min_list.remove(minimum)
	print(sum(a))


def call():
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	b = b[::-1]
	sum = 0
	for i in range(n):
		if i < k:
			sum += max(a[i], b[i])
		else:
			sum += a[i]
	print(sum)
t = int(input())
for _ in range(t):
	call()


def maxArraySum(a, b, k):
	maxVal = max(b)
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < len(a) and a[i] < b[i] and (k > 0):
		a[i] = b[i]
		i += 1
		k -= 1
	return sum(a)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(maxArraySum(a, b, k))


for _ in range(int(input())):
	l = list(input().split(' '))
	a = list(input().split(' '))
	b = list(input().split(' '))
	k = int(l[1])
	n = int(l[0])
	for z in range(0, n):
		x = int(a[z])
		a[z] = x
		y = int(b[z])
		b[z] = y
	a.sort()
	b.sort()
	sum = 0
	for i in range(0, n):
		sum += a[i]
	for j in range(0, k):
		if b[n - j - 1] > a[j]:
			sum = sum + b[n - j - 1] - a[j]
		else:
			break
	print(sum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	i = 0
	j = n - 1
	c = 0
	while c < k and i < n and (j < n):
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			i += 1
		j -= 1
		c += 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr.sort()
	brr.sort(reverse=True)
	mx = sum(arr)
	i = 0
	j = 0
	while i < n and j < n:
		if arr[i] < brr[j] and k > 0:
			(arr[i], brr[j]) = (brr[j], arr[i])
			k -= 1
			i += 1
			j += 1
		else:
			j += 1
	print(max(mx, sum(arr)))


t = int(input())
while t > 0:
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	s = sum(a)
	i = 0
	while i < k:
		if a[i] < b[i]:
			s -= a[i]
			s += b[i]
		else:
			break
		i += 1
	print(s)
	t -= 1


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
		else:
			break
	print(sum(a))


m = int(input())
for i in range(m):
	(n, k) = map(int, input().split())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[n - 1 - i]:
			(a[i], b[n - 1 - i]) = (b[n - 1 - i], a[i])
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if n == k:
		output = sorted(a + b)
		print(sum(output[-n:]))
	else:
		a = sorted(a)
		b = sorted(b)
		i = 0
		while min(a) < max(b) and k > 0:
			(a[i], b[n - i - 1]) = (b[n - i - 1], a[i])
			k -= 1
			i += 1
		print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		c = min(a)
		d = max(b)
		if c < d:
			(a[a.index(c)], b[b.index(d)]) = (d, c)
		else:
			break
	print(sum(a))


def solve():
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	b = sorted(map(int, input().split()), reverse=True)
	ans = sum(a)
	for i in range(k + 1):
		ans = max(ans, sum(a[:n - i]) + sum(b[:i]))
	print(ans)
t = int(input())
for _ in range(t):
	solve()


def mini(ar):
	minimum = 31
	for i in ar:
		if i < minimum:
			minimum = i
	return minimum

def maxi(ar):
	maximum = -1
	for i in ar:
		if i > maximum:
			maximum = i
	return maximum
t = int(input())
while t:
	summation = 0
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k:
		if mini(a) < maxi(b):
			a[a.index(mini(a))] = maxi(b)
			b.remove(maxi(b))
			k = k - 1
		else:
			break
	for j in a:
		summation = summation + j
	print(summation)
	t = t - 1


R = lambda : [*map(int, input().split())]
(t,) = R()
for _ in [0] * t:
	(n, k) = R()
	a = R()
	b = R()
	for _ in [0] * k:
		i = a.index(min(a))
		j = b.index(max(b))
		(b[j], a[i]) = sorted((a[i], b[j]))
	print(sum(a))


t = int(input())
i = 0
while i < t:
	i += 1
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = input()
	a = a.split()
	b = input()
	b = b.split()
	j = 0
	while j < n:
		a[j] = int(a[j])
		b[j] = int(b[j])
		j += 1
	a.sort()
	b.sort()
	j = 0
	while j < k:
		if a[j] < b[n - 1 - j]:
			a[j] = b[n - 1 - j]
		j += 1
	print(sum(a))


def arraySwap(a, b, k):
	a.sort()
	b.sort(reverse=True)
	pA = pB = 0
	while k > 0 and pA < len(a) and (pB < len(b)):
		if a[pA] < b[pB]:
			a[pA] = b[pB]
			k -= 1
		pA += 1
		pB += 1
	sumA = 0
	for num in a:
		sumA += num
	print(sumA)
numTestCases = int(input())
for i in range(numTestCases):
	k = int(input().split(' ')[-1])
	a = [int(num) for num in input().split(' ')]
	b = [int(num) for num in input().split(' ')]
	arraySwap(a, b, k)


def fun(a, b, n, k):
	while k:
		x = min(a)
		y = max(b)
		if y <= x:
			return sum(a)
		else:
			a.remove(x)
			b.remove(y)
			a.append(y)
		k -= 1
	return sum(a)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(fun(a, b, n, k))


n = int(input())
tests = [(input(), input(), input()) for _ in range(n)]
ans = []
for (_, a, b) in tests:
	(n, k) = map(int, _.split())
	a = list(map(int, a.split()))
	b = list(map(int, b.split()))
	a.sort()
	b.sort()
	for i in range(1, k + 1):
		if b[-i] > a[i - 1]:
			(a[i - 1], b[-i]) = (b[-i], a[i - 1])
	ans.append(sum(a))
[print(_) for _ in ans]


t = int(input())
for qwe in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		minn = min(a)
		maxx = max(b)
		if minn >= maxx:
			break
		else:
			a.append(maxx)
			b.append(minn)
			a.remove(minn)
			b.remove(maxx)
	print(sum(a))


n = int(input())
for _ in range(n):
	(length, n_swap) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for _ in range(n_swap):
		if min(a) < max(b):
			(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
	print(sum(a))


def s_m(l):
	k = 0
	for i in range(len(l)):
		k += l[i]
	return k

def s_rt(l):
	for i in range(len(l)):
		for j in range(i, len(l)):
			if l[i] > l[j]:
				(l[i], l[j]) = (l[j], l[i])
	return l

def r_verse(l):
	n = len(l)
	for i in range(n // 2):
		(l[i], l[-i - 1]) = (l[-i - 1], l[i])
	return l

def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s_rt(a)
	s_rt(b)
	r_verse(b)
	x = 0
	y = 0
	for i in range(k):
		if a[x] < b[y]:
			a[x] = b[y]
		x += 1
		y += 1
	ans = s_m(a)
	print(ans)
t = int(input())
for i in range(t):
	solve()


try:
	t = int(input())
	for i in range(t):
		(n, k) = input().split(' ')
		n = int(n)
		k = int(k)
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		for i in range(k):
			if min(a) > max(b):
				break
			elif min(a) < max(b):
				c = a.index(min(a))
				d = b.index(max(b))
				(a[c], b[d]) = (b[d], a[c])
		print(sum(a))
except Exception as e:
	print(e)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(sorted(map(int, input().split())))
	b = list(reversed(sorted(map(int, input().split()))))
	print(sum(list(sorted(a[:k] + b[:k]))[k:] + a[k:]))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
from copy import deepcopy
mod2 = 998244353

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

def out(var, end='\n'):
	sys.stdout.write(str(var) + end)

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, k) = sp()
	(a, b) = (l(), l())
	a.sort()
	b.sort()
	answer = 0
	while n:
		n -= 1
		if k and b and (b[-1] > a[-1]):
			k -= 1
			answer += b.pop()
		else:
			answer += a.pop()
	out(answer)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()))
	(i, j) = (0, n - 1)
	while i < n and j >= 0 and (k > 0):
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			i += 1
			j -= 1
			k -= 1
		else:
			j -= 1
	print(sum(a))


t = int(input())
i = 0
while i < t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b = b[::-1]
	j = 0
	while j < m:
		if b[j] > a[j]:
			a[j] = b[j]
		else:
			break
		j += 1
	(k, l) = (0, 0)
	while l < n:
		k += a[l]
		l += 1
	print(k)
	i += 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		q = min(a)
		w = max(b)
		if q < w:
			a[a.index(q)] = w
			b.remove(w)
			b.append(q)
		else:
			break
	print(sum(a))


import sys
sys.setrecursionlimit(2000)
from collections import Counter
from functools import reduce
t = [int(val) for val in sys.stdin.readline().split()][0]
for test in range(t):
	(n, k) = [int(val) for val in sys.stdin.readline().split()]
	a = [int(val) for val in sys.stdin.readline().split()]
	b = [int(val) for val in sys.stdin.readline().split()]
	a.sort()
	b.sort()
	ind1 = 0
	ind2 = len(b) - 1
	count = 0
	while ind1 < len(a) and ind2 >= 0 and (a[ind1] < b[ind2]):
		if count == k:
			break
		tmp = b[ind2]
		b[ind2] = a[ind1]
		a[ind1] = tmp
		count += 1
		ind1 += 1
		ind2 -= 1
	print(sum(a))


def solve():
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	b.sort(reverse=True)
	a += b[:k]
	a.sort(reverse=True)
	print(sum(a[:n]))
for _ in range(int(input())):
	solve()


class solution:

	def __init__(self, n, k, a, b):
		self.n = n
		self.k = k
		self.a = sorted(a)
		self.b = sorted(b)
		self.sum_a = 0

	def calculation(self):
		for j in range(self.n):
			if j == self.k:
				break
			if self.a[j] < self.b[self.n - 1 - j]:
				self.a[j] = self.b[self.n - 1 - j]
		self.SumList()

	def SumList(self):
		for i in self.a:
			self.sum_a += i
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	root = solution(n, k, a, b)
	root.calculation()
	print(root.sum_a)


from sys import stdin, exit, setrecursionlimit
from collections import deque
from heapq import *
from math import gcd
from math import ceil, log2
setrecursionlimit(10000000)
from collections import deque
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
for _ in range(int(input())):
	(n, k) = mi()
	a = lmi()
	b = lmi()
	s = sum(a)
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[n - i - 1]:
			s -= a[i]
			s += b[n - i - 1]
		else:
			break
	print(s)


def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = [int(x) for x in input().split()]
		b = [int(x) for x in input().split()]
		a.sort()
		b.sort()
		for i in range(k):
			if b[-1] > a[0]:
				a.remove(a[0])
				a.append(b[-1])
				b.remove(b[-1])
			else:
				break
		print(sum(a))
main()


import sys
from math import sqrt
sys.setrecursionlimit(10 ** 6)
nofkase = int(input())
for kase in range(nofkase):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	ans = 0
	i = 0
	while i < k and b[i] > a[i]:
		ans += b[i]
		i += 1
	ans += sum(a[i:])
	print(ans)


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


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for _ in range(k):
		if min(a) < max(b):
			aidx = a.index(min(a))
			bidx = b.index(max(b))
			(a[aidx], b[bidx]) = (b[bidx], a[aidx])
	print(sum(a))


t = int(input())
result = []
for _ in range(t):
	(n, k) = [int(var) for var in input().split(' ')]
	a = []
	b = []
	elements_a = input().split(' ')
	elements_b = input().split(' ')
	for i in range(len(elements_a)):
		a.append(int(elements_a[i]))
		b.append(int(elements_b[i]))
	a.sort()
	b.sort()
	max_tol = 0
	tmp = 1
	for i in range(len(a)):
		if a[i] < b[-tmp] and tmp <= k:
			max_tol += b[-tmp]
			tmp += 1
		else:
			max_tol += a[i]
	result.append(max_tol)
for item in result:
	print(item)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	arrayA = sorted(map(int, input().split()))
	arrayB = sorted(map(int, input().split()), reverse=True)
	if k == 0:
		print(sum(arrayA))
	else:
		for i in range(k):
			if arrayA[i] < arrayB[i]:
				arrayA[i] = arrayB[i]
		print(sum(arrayA))


tc = int(input())
for _ in range(tc):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	ans = []
	arr.sort()
	brr.sort(reverse=True)
	i = 0
	while k > 0 and i < len(arr) and (brr[i] > arr[i]):
		ans.append(brr[i])
		i += 1
		k -= 1
	ans.extend(arr[i:])
	print(sum(ans))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	list1.sort()
	list2.sort()
	for i in range(k):
		if list1[i] < list2[n - i - 1]:
			list1[i] = list2[n - i - 1]
	print(sum(list1))


import sys, math, bisect
from collections import Counter, defaultdict as dd

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

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
for _ in range(int(data())):
	(n, k) = sp()
	a = l()
	b = l()
	a.sort()
	b.sort(reverse=True)
	c = 0
	for i in range(n):
		if c == k:
			break
		elif a[i] < b[i]:
			a[i] = b[i]
			c += 1
	print(sum(a))


import collections
import operator
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	a.sort()
	b.sort(reverse=True)
	idxa = 0
	idxb = 0
	while k > 0 and idxa < n and (idxb < n):
		if a[idxa] < b[idxb]:
			(a[idxa], b[idxb]) = (b[idxb], a[idxa])
			k -= 1
			idxb += 1
		idxa += 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if k == 0:
		print(sum(a))
	elif min(a) >= max(b):
		print(sum(a))
	else:
		a.sort()
		b.sort(reverse=True)
		i = 0
		j = 0
		while k != 0 and min(a) < max(b):
			(a[i], b[j]) = (b[j], a[i])
			i += 1
			j += 1
			k -= 1
		print(sum(a))


r = int(input())
list8 = []
for i in range(r):
	(y, k) = map(int, input().split())
	list1 = sorted(list(map(int, input().split())))
	list2 = sorted(list(map(int, input().split())), reverse=True)
	for y in range(k):
		if list2[y] > list1[y]:
			list1[y] = list2[y]
	list8.append(sum(list1))
for u in list8:
	print(u)


for case in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	ans = 0
	a = input().split()
	b = input().split()
	for i in range(n):
		b[i] = int(b[i])
		a[i] = int(a[i])
		ans += a[i]
	a = sorted(a)
	b = sorted(b)
	stp = 0
	l = 0
	r = n - 1
	while stp < k:
		if a[l] < b[r]:
			ans -= a[l]
			ans += b[r]
			l += 1
			r -= 1
			stp += 1
		else:
			break
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	while k > 0:
		k -= 1
		m1 = min(a)
		m2 = max(b)
		if m1 < m2:
			a[a.index(m1)] = m2
			b.remove(m2)
	print(sum(a))


import heapq

class MaxHeapObj(object):

	def __init__(self, val):
		self.val = val

	def __lt__(self, other):
		return self.val > other.val

	def __eq__(self, other):
		return self.val == other.val

	def __str__(self):
		return str(self.val)

class MinHeap(object):

	def __init__(self):
		self.h = []

	def heappush(self, x):
		heapq.heappush(self.h, x)

	def heappop(self):
		return heapq.heappop(self.h)

	def __getitem__(self, i):
		return self.h[i]

	def __len__(self):
		return len(self.h)

class MaxHeap(MinHeap):

	def heappush(self, x):
		heapq.heappush(self.h, MaxHeapObj(x))

	def heappop(self):
		return heapq.heappop(self.h).val

	def __getitem__(self, i):
		return self.h[i].val
T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	a_original = list(map(int, input().split()))
	b_original = list(map(int, input().split()))
	a_minHeap = MinHeap()
	for a_num in a_original:
		a_minHeap.heappush(a_num)
	a_maxHeap = MaxHeap()
	for a_num in a_original:
		a_maxHeap.heappush(a_num)
	b_minHeap = MinHeap()
	for b_num in b_original:
		b_minHeap.heappush(b_num)
	b_maxHeap = MaxHeap()
	for b_num in b_original:
		b_maxHeap.heappush(b_num)
	for i in range(k):
		min_a = a_minHeap.heappop()
		max_b = b_maxHeap.heappop()
		a_minHeap.heappush(max(max_b, min_a))
	print(sum(a_minHeap.h))


a = int(input())
for i in range(a):
	(b, c) = map(int, input().split())
	d = list(map(int, input().split()))
	e = list(map(int, input().split()))
	d.sort()
	e.sort()
	for i in range(c):
		if e[-i - 1] > d[i]:
			(d[i], e[-i - 1]) = (e[-i - 1], d[i])
		else:
			break
	print(sum(d))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().strip().split(' '))
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	for j in range(k):
		if min(a) < max(b):
			minpos = a.index(min(a))
			maxpos = b.index(max(b))
			temp = a[minpos]
			a[minpos] = b[maxpos]
			b[maxpos] = temp
		else:
			break
	print(sum(a))


t = int(input())
for _ in range(t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	while k != 0:
		if min(a) < max(b):
			t = min(a)
			a[a.index(min(a))] = b[b.index(max(b))]
			b[b.index(max(b))] = t
		k -= 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()], reverse=True)
	for __ in range(k):
		if a[0] < b[0]:
			(a[0], b[0]) = (b[0], a[0])
			a = sorted(a)
			b = sorted(b, reverse=True)
	print(sum(a))


import sys
input = sys.stdin.buffer.readline

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

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
for __ in range(int(input())):
	(n, k) = I()
	a = I()
	b = I()
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < n and a[i] < b[i] and (i < k):
		i += 1
	print(sum(b[:i]) + sum(a[i:]))


import sys
input = sys.stdin.buffer.readline
t = int(input())
for case in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = sum(a)
	for i in range(k):
		min_a = 30
		max_b = 0
		idx = [0, 0]
		for i in range(n):
			if a[i] < min_a:
				idx[0] = i
				min_a = a[i]
			if b[i] > max_b:
				idx[1] = i
				max_b = b[i]
		if max_b > min_a:
			ans += max_b - min_a
			(a[idx[0]], b[idx[1]]) = (max_b, min_a)
	print(ans)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort(reverse=True)
	B.sort(reverse=True)
	i = n - 1
	j = 0
	while k > 0:
		if A[i] < B[j]:
			(A[i], B[j]) = (B[j], A[i])
			i -= 1
			j += 1
		else:
			break
		k -= 1
	print(sum(A))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	for i in range(min(n, k)):
		if a[i] < b[-i - 1]:
			a[i] = b[-i - 1]
		else:
			break
	print(sum(a))


def arrswaps(n, a, b, k):
	a.sort()
	b.sort(reverse=True)
	j = 0
	while k != 0 and j < n:
		if a[j] < b[j]:
			(a[j], b[j]) = (b[j], a[j])
		else:
			break
		j += 1
		k -= 1
	return sum(a)
test = int(input())
for i in range(test):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(arrswaps(n, a, b, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr.sort()
	brr.sort()
	i = 0
	j = n - 1
	while k > 0:
		k -= 1
		if arr[i] > brr[j]:
			break
		else:
			arr[i] = brr[j]
			i += 1
			j -= 1
	print(sum(arr))


from sys import stdin, stdout
from pprint import pprint
for _ in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	b.sort()
	if k > 0:
		a = a + b[-k:]
	a.sort()
	stdout.write(str(sum(a[-n:])) + '\n')


N = int(input())
for _ in range(N):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(list(map(int, input().split())), reverse=True)
	new = sorted(a + b[:k], reverse=True)
	print(sum(new[:n]))


n = int(input())
import math
for xy in range(n):
	t = list(map(int, input().split()))
	q = sorted(list(map(int, input().split())))
	ms = sorted(list(map(int, input().split())))
	n = t[0]
	m = t[1]
	for xy in range(m):
		if q[xy] < ms[-1 * xy - 1]:
			q[xy] = ms[-1 * xy - 1]
	print(sum(q))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	list1.sort()
	list2.sort()
	x = 0
	y = n - 1
	for i in range(k):
		if list1[x] < list2[y]:
			list1[x] = list2[y]
			x += 1
			y -= 1
		else:
			break
	print(sum(list1))


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	A = sorted(list(map(int, input().split())))
	B = sorted(list(map(int, input().split())))
	B.reverse()
	total = sum(A)
	for i in range(K):
		if B[i] <= A[i]:
			break
		total = total - A[i] + B[i]
	print(total)


def main():
	STR = input().split(' ')
	n = int(STR[0])
	k = int(STR[1])
	listA = []
	listB = []
	STRA = input().split(' ')
	STRB = input().split(' ')
	sum1 = 0
	for i in STRA:
		listA.append(int(i))
		sum1 += int(i)
	for i in STRB:
		listB.append(int(i))
	listA.sort()
	listB.sort()
	i = 0
	j = n - 1
	while i < n and k > 0:
		if listA[i] < listB[j]:
			k -= 1
			sum1 -= listA[i]
			sum1 += listB[j]
		else:
			break
		i += 1
		j -= 1
	print(sum1)
t = int(input())
for i in range(t):
	main()


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	for q in range(k):
		if i == n or j == -1:
			break
		if a[i] < b[j]:
			a[i] = b[j]
			i += 1
			j -= 1
	return sum(a)
t = int(input())
for loop in range(t):
	print(solve())


import sys
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
for t in range(int(input())):
	(n, k) = intInp()
	a = intInp()
	b = intInp()
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	if k == 0:
		print(sum(a))
		continue
	for i in range(k):
		if a[i] <= b[i]:
			a[i] = b[i]
	print(sum(a))


t = int(input())
for _ in range(0, t):
	(n, k) = map(int, input().split())
	li1 = list(map(int, input().split()))
	li2 = list(map(int, input().split()))
	for i in range(0, n):
		li1[i] = [li1[i], 1]
	for i in range(0, n):
		li2[i] = [li2[i], 2]
	li = li1 + li2
	li.sort(reverse=1)
	ans = 0
	cnt = 0
	for i in li:
		if i[1] == 2 and k > 0:
			ans += i[0]
			k -= 1
			cnt += 1
		elif i[1] == 1:
			ans += i[0]
			cnt += 1
		if cnt == n:
			break
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	first = list(map(int, input().split()))
	second = list(map(int, input().split()))
	first.sort()
	second.sort()
	for i in range(k):
		if second[-(i + 1)] > first[i]:
			(first[i], second[-(i + 1)]) = (second[-(i + 1)], first[i])
	print(sum(first))


t = int(input())
for z in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort(reverse=True)
	b.sort(reverse=True)
	summ = 0
	i = j = index = 0
	half = a[:n - k]
	summ += sum(half)
	i = n - k
	half1 = a[i:]
	half1.extend(b)
	half1.sort(reverse=True)
	res = half1[:k]
	summ += sum(res)
	print(summ)


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

def solve():
	(n, k) = RA()
	a = RA()
	b = RA()
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] >= b[i]:
			break
		a[i] = b[i]
	print(sum(a))
t = int(input())
for i in range(t):
	solve()


def solution(k, a, b):
	if k == 0:
		print(sum(a))
		return
	a.sort()
	b.sort()
	c = list()
	c.extend(a[:k])
	c.extend(b[-k:])
	c.sort()
	print(sum(a[k:]) + sum(c[-k:]))
inp = int(input())
for _ in range(inp):
	(_, k) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solution(k, a, b)


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	for i in range(k):
		if a[i] >= b[n - i - 1]:
			break
		a[i] = b[n - i - 1]
	print(sum(a))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	first = list(map(int, input().split()))
	second = list(map(int, input().split()))
	if m == 0:
		print(sum(first))
		continue
	else:
		first.sort()
		second.sort(reverse=True)
		i = 0
		while m > 0:
			if first[i] < second[i]:
				(first[i], second[i]) = (second[i], first[i])
			i += 1
			m -= 1
		print(sum(first))


def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = [int(i) for i in input().split()]
		b = [int(i) for i in input().split()]
		a.sort()
		b.sort(reverse=True)
		i = 0
		while k and i < n:
			if a[i] >= b[i]:
				break
			else:
				a[i] = b[i]
				i += 1
				k -= 1
		ans = 0
		for i in a:
			ans += i
		print(ans)
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if min(a) >= max(b):
		print(sum(a))
	else:
		sm = sum(a)
		for i in range(k):
			ind = a.index(min(a))
			a[ind] = max(b)
			b.remove(max(b))
			if sum(a) < sm:
				break
			else:
				sm = sum(a)
		print(sm)


for j in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	for i in range(m):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()))
	i = 0
	for j in range(k):
		if a[j] < b[len(b) - j - 1]:
			a[j] = b[len(b) - j - 1]
		else:
			break
	print(sum(a))


t = int(input())
for c in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(y) for y in input().split()]
	b = [int(z) for z in input().split()]
	if k == 0:
		print(sum(a))
	else:
		a.sort()
		b.sort(reverse=True)
		for i in range(k):
			if b[i] > a[i]:
				a[i] = b[i]
		print(sum(a))


t = int(input())
for i in range(t):
	summ = 0
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		mina = 31
		maxb = 0
		for k in range(n):
			if a[k] <= mina:
				mina = a[k]
				inda = k
			if b[k] >= maxb:
				maxb = b[k]
				indb = k
		if mina > maxb:
			break
		(a[inda], b[indb]) = (b[indb], a[inda])
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(j) for j in input().split()]
	b = [int(l) for l in input().split()]
	a.sort()
	b.sort()
	p1 = 0
	p2 = len(b) - 1
	while k > 0:
		if b[p2] > a[p1]:
			p2 -= 1
			p1 += 1
			k -= 1
		else:
			break
	print(sum(a[p1:]) + sum(b[p2 + 1:]))


n = int(input())
for i in range(n):
	s = input().split(' ')
	q1 = int(s[0])
	q = int(s[1])
	s1 = input().split(' ')
	a = []
	for c in s1:
		a.append(int(c))
	s2 = input().split(' ')
	b = []
	for c in s2:
		b.append(int(c))
	a.sort()
	b.sort()
	b.reverse()
	_sum = 0
	for i in range(q):
		_sum += max(a[i], b[i])
	for i in range(q, q1):
		_sum += a[i]
	print(_sum)


def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a1 = sorted(a)
		b1 = sorted(b)
		b1.reverse()
		for i in range(k):
			if a1[i] < b1[i]:
				a1[i] = b1[i]
		print(sum(a1))
main()


import sys
input = lambda : sys.stdin.readline().rstrip()
out = []
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	s = a + b[:k]
	s.sort(reverse=True)
	ans = sum(s[:n])
	out.append(str(ans))
print('\n'.join(out))


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	l1 = sorted(list(map(int, input().split())))
	l2 = sorted(list(map(int, input().split())))
	i = 0
	j = len(l2) - 1
	g = len(l2) - 1
	while b > 0 and j >= 0:
		if l1[i] < l2[j]:
			(l1[i], l2[j]) = (l2[j], l1[i])
		i += 1
		j -= 1
		b -= 1
	print(sum(l1))


t = int(input())
while t:
	t = t - 1
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	b = sorted(list(map(int, input().split())), reverse=True)
	c = sorted(a[n - k:n] + b[:k], reverse=True)
	print(sum(a[:n - k] + c[:k]))


t = int(input(''))
for i in range(0, t):
	x = input('')
	a = input('')
	b = input('')
	a = a.split()
	a = [int(i) for i in a]
	b = b.split()
	b = [int(i) for i in b]
	x = x.split()
	x = [int(i) for i in x]
	n = x[0]
	k = x[1]
	a.sort()
	b.sort()
	for j in range(0, k):
		if a[0] <= b[-1]:
			temp = a[0]
			a[0] = b[-1]
			b[-1] = temp
			a.sort()
			b.sort()
	print(sum(a))


def solve(arr1, arr2, k):
	if k < 1:
		return sum(arr1)
	if len(arr1) == 0 or len(arr2) == 0:
		return 0
	if len(arr1) != len(arr2):
		return None
	if len(arr1) > 1:
		arr1.sort()
		arr2.sort(reverse=True)
	l = 0
	while l < k:
		if arr1[l] < arr2[l]:
			arr1[l] = arr2[l]
		l += 1
	return sum(arr1)

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

def readData():
	t = int(input())
	for _ in range(t):
		(_, k) = readInt()
		arr1 = readInt()
		arr2 = readInt()
		print(solve(arr1, arr2, k))
readData()


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	for i in range(k):
		A[i] = max(A[i], B[n - i - 1])
	print(sum(A))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr1 = [int(i) for i in input().split()]
	arr2 = [int(i) for i in input().split()]
	arr1.sort()
	arr2 = sorted(arr2)[::-1]
	arr3 = []
	for i in range(n):
		if k > 0:
			if arr2[i] > arr1[i]:
				arr3.append(arr2[i])
				k -= 1
			else:
				arr3.append(arr1[i])
		else:
			arr3.append(arr1[i])
	print(sum(arr3))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		if max(b) > min(a):
			l = a.index(min(a))
			a[l] = max(b)
			b.remove(max(b))
	print(sum(a))


import math
import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	a.sort()
	b.sort(reverse=True)
	s = 0
	s2 = sum(a)
	i = 0
	x = 0
	while i < k and b[i] > a[i]:
		s += b[i]
		i += 1
		x = i
	for i in range(x, n):
		s += a[i]
	print(s)


def what(a, b, n, k):
	for i in range(k):
		x = max(b)
		y = min(a)
		if x >= y:
			b.remove(x)
			a.remove(y)
			a.append(x)
	print(sum(a))
t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ans = what(a, b, n, k)
	ans


for x in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	z = []
	for i in range(n):
		z.append(a[i])
	for i in range(k):
		z.append(b[i])
	z.sort(reverse=True)
	k = 0
	for i in range(n):
		k += z[i]
	print(k)


t = int(input().strip())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
		else:
			break
	print(sum(a))


import sys, os, time, json, random, math
t = int(input())
res = []
for i in range(t):
	(n, k) = [int(_) for _ in input().split()]
	a = [int(_) for _ in input().split()]
	b = [int(_) for _ in input().split()]
	b = sorted(b, reverse=True)
	a = sorted(a)
	m = sum(a)
	for j in range(k):
		a[j] = b[j]
		m = max(m, sum(a))
	res.append(m)
for r in res:
	print(r)


x = int(input())
for i in range(x):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	s = 0
	for i in range(k):
		if a[i] < b[i]:
			s += 1
		else:
			break
	print(sum(b[:s]) + sum(a[s:]))


try:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		arr1 = list(map(int, input().split()))
		arr2 = list(map(int, input().split()))
		arr1.sort()
		arr2.sort(reverse=True)
		for i in range(k):
			k1 = min(arr1)
			i1 = arr1.index(k1)
			k2 = max(arr2)
			i2 = arr2.index(k2)
			if k1 < k2:
				(arr1[i1], arr2[i2]) = (arr2[i2], arr1[i1])
			else:
				break
		print(sum(arr1))
except EOFError:
	pass


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = sorted(map(int, input().split()))
		b = sorted(map(int, input().split()), reverse=True)
		for i in range(k):
			if a[i] >= b[i]:
				break
			a[i] = b[i]
		print(sum(a))
main()


rr = lambda : input().strip()
rrm = lambda : map(int, rr().split())
T = int(rr())
for _ in range(T):
	(n, k) = rrm()
	a = list(rrm())
	b = list(rrm())
	c = 0
	ma = sum(a)
	while c < k:
		i = a.index(min(a))
		j = b.index(max(b))
		(a[i], b[j]) = (b[j], a[i])
		c += 1
		temp = sum(a)
		if temp <= ma:
			break
		else:
			ma = temp
	print(ma)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = sum(a)
	for i in range(k):
		change = b[-i - 1] - a[i]
		if change > 0:
			ans += change
	print(ans)


try:
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		while k > 0:
			x = min(a)
			y = max(b)
			if y > x:
				p = a.index(x)
				q = b.index(y)
				a[p] = y
				b[q] = x
			else:
				break
			k -= 1
		print(sum(a))
except EOFError:
	pass


def solution(a, b, k):
	a = sorted(a)
	b = sorted(b)
	n = len(a)
	count = 0
	i = 0
	while count < k:
		count += 1
		a[i] = max(a[i], b[n - i - 1])
		i += 1
	return sum(a)
t = int(input())
while t > 0:
	t -= 1
	k = int(input().split()[1])
	a = map(int, input().split())
	b = map(int, input().split())
	print(solution(a, b, k))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			x = a.pop(i)
			y = b.pop(i)
			b.insert(i, x)
			a.insert(i, y)
	print(sum(a))


def Hello(a, l, k):
	a.sort()
	l.sort(reverse=True)
	for i in range(k):
		if l[i] > a[i]:
			(a[i], l[i]) = (l[i], a[i])
		else:
			break
	print(sum(a))
t = int(input())
for _ in range(t):
	nk = input().split()
	(n, k) = (int(nk[0]), int(nk[1]))
	a = list(map(int, input().split()))
	l = list(map(int, input().split()))
	Hello(a, l, k)


import copy
z = int(input())
min_a = []
max_b = []
otv = []
for _ in range(z):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k > 0 and min(a) < max(b):
		a.append(max(b))
		a.remove(min(a))
		b.remove(max(b))
		k -= 1
	otv.append(sum(a))
for _ in range(z):
	print(otv[_])


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')
import math

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

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, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def divisor(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return i
	return n
import math
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		a.sort()
		b.sort()
		if a[0] > b[-1]:
			break
		(a[0], b[-1]) = (b[-1], a[0])
	print(sum(a))


import sys
import math

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

def idata():
	return [int(x) for x in ii().split()]

def solve_of_problem():
	(n, k) = idata()
	a = sorted(idata())
	b = sorted(idata())
	ans = 0
	for i in range(n):
		if k > 0:
			ans += max(a[i], b[n - i - 1])
			k -= 1
		else:
			ans += a[i]
	print(ans)
	return
for ______ in range(int(ii())):
	solve_of_problem()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ans = sum(a)
	for i in range(k):
		v = b[i] - a[i]
		if v > 0:
			ans += v
	print(ans)


def maximizeA(n, k, a, b):
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < k and a[i] < b[i]:
		a[i] = b[i]
		i += 1
	return sum(a)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(maximizeA(n, k, a, b))


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


n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	m = 0
	n = len(b) - 1
	for i in range(y):
		if a[m] < b[n]:
			a[m] = b[n]
			m += 1
			n = n - 1
	s = sum(a)
	print(s)


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for _ in range(k):
		mini = min(a)
		maxi = max(b)
		if mini < maxi:
			a[a.index(mini)] = maxi
			b[b.index(maxi)] = mini
		else:
			break
	print(sum(a))
for _ in range(int(input())):
	solve()


a = int(input())
for _ in range(a):
	(y, x) = map(int, input().split())
	li1 = list(map(int, input().split()))
	li2 = list(map(int, input().split()))
	li1.sort()
	li2.sort(reverse=True)
	i = 0
	while x:
		if li1[i] > li2[i]:
			break
		li1[i] = li2[i]
		x -= 1
		i += 1
	print(sum(li1))


t = int(input())
for tc in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))


import collections
import itertools
import sys
from collections import defaultdict, Counter
from math import sqrt, ceil
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())

def main():
	n = inp()
	for _ in range(n):
		(a, k) = inlt()
		c1 = inlt()
		c2 = inlt()
		c1.sort()
		c2.sort(reverse=True)
		for i in range(k):
			if c1[i] < c2[i]:
				c1[i] = c2[i]
		print(sum(c1))
main()


import math
t = int(input())
import math
delay = []
for _ in range(t):
	(n, k) = map(int, input().split())
	a = input().split()
	a = [int(i) for i in a]
	b = input().split()
	b = [int(i) for i in b]
	a.sort()
	b.sort(reverse=True)
	cnt = 0
	apt = 0
	bpt = 0
	while cnt < k and apt < n and (bpt < n):
		if a[apt] < b[bpt]:
			temp = a[apt]
			a[apt] = b[bpt]
			b[bpt] = temp
			if bpt < n - 1 and temp > b[bpt + 1]:
				break
			apt += 1
		else:
			break
		bpt += 1
		cnt += 1
	delay.append(sum(a))
for d in delay:
	print(d)


nc = int(input())
for c in range(nc):
	(n, k) = [int(x) for x in input().strip().split()]
	a = list(zip([int(x) for x in input().strip().split()], [0] * n))
	b = list(zip([int(x) for x in input().strip().split()], [1] * n))
	s = a + b
	s.sort(reverse=True)
	(ct, ans) = (0, 0)
	for (v, i) in s:
		if ct == len(a):
			break
		if i == 1:
			if k > 0:
				k -= 1
				ans += v
				ct += 1
		else:
			ans += v
			ct += 1
	print(ans)


from collections import defaultdict
import heapq

def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	suma = sum(a)
	while k:
		k -= 1
		mina = min(a)
		maxb = max(b)
		if mina < maxb:
			suma -= mina
			suma += maxb
			a.pop(a.index(mina))
			a.append(maxb)
			b.pop(b.index(maxb))
	print(suma)
for _ in range(int(input())):
	solve()


testcases = int(input())
for i in range(testcases):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	if b[0] <= a[0]:
		print(sum(a))
	else:
		i = 0
		j = 0
		while i < len(a) and j < len(b) and (k > 0):
			if b[j] > a[i]:
				temp = a[i]
				a[i] = b[j]
				b[j] = temp
				k -= 1
				j += 1
				i += 1
			elif a[i] == b[j] or b[j] < a[i]:
				break
		print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ad = a[0:]
	ad.sort()
	b.sort(reverse=True)
	for i in range(k):
		temp = b[i]
		for j in range(n):
			if ad[j] < temp:
				ad[j] = temp
				break
	print(sum(ad))


def swap(alist, blist, n, k):
	alist.sort()
	blist.sort()
	total = 0
	for i in alist:
		total += i
	for i in range(k):
		if alist[i] < blist[-(i + 1)]:
			total = total - alist[i] + blist[-(i + 1)]
		else:
			break
	print(total)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	alist = list(map(int, input().split()))
	blist = list(map(int, input().split()))
	swap(alist, blist, n, k)


t = int(input())
while t > 0:
	t -= 1
	n = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	while n[1] > 0:
		n[1] -= 1
		a.sort()
		b.sort()
		if b[-1] > a[0]:
			temp = a[0]
			a[0] = b[-1]
			b[-1] = temp
		else:
			break
	print(sum(a))


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	if min(a) >= max(b):
		answer = sum(a)
	else:
		for i in range(n):
			if k > 0:
				j = 0
				if min(a) >= max(b):
					answer = sum(a)
				else:
					while a[i] >= b[j] and j < n:
						j += 1
					if j < n and b[j] > a[i]:
						a[i] = b[j]
						b[j] = 0
						k -= 1
					else:
						continue
			else:
				break
		answer = sum(a)
	print(answer)


for _ in range(int(input())):
	(n, k) = list(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	s = sum(a)
	while k > 0:
		(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
		s = max(s, sum(a))
		k -= 1
	print(s)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		maxb = max(b)
		posmaxb = b.index(maxb)
		mina = min(a)
		posmina = a.index(mina)
		if maxb > mina:
			(a[posmina], b[posmaxb]) = (b[posmaxb], a[posmina])
		else:
			break
	print(sum(a))


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

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

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

def inmap():
	return map(int, input().split())
for t in range(inp()):
	(n, k) = inmap()
	a = inlt()
	b = inlt()
	b.sort(reverse=True)
	a.sort()
	x = 0
	y = 0
	for i in range(k):
		if a[x] < b[y]:
			a[x] = b[y]
			x += 1
			y += 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	c = a + b[:k]
	c.sort(reverse=True)
	ans = sum(c[:n])
	print(ans)


for x in range(int(input())):
	a = list(map(int, input().split()))
	n = a[0]
	k = a[-1]
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	b.sort()
	c.sort()
	i = 0
	s = 0
	while i < k and s != 1:
		min_b = b[i]
		max_c = c[n - i - 1]
		if min_b < max_c:
			b[i] = c[n - i - 1]
		else:
			s = 1
		i += 1
	print(sum(b))


test_case = int(input())
for _ in range(test_case):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if max(b) == min(a):
		print(sum(a))
	elif k == 0:
		print(sum(a))
	else:
		temp_max = sum(a)
		for i in range(k):
			(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
			temp_max = max(temp_max, sum(a))
		print(temp_max)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	for j in range(k):
		if a[j] < b[n - 1 - j]:
			a[j] = b[n - 1 - j]
		else:
			break
	print(sum(a))


test_cases = int(input())

def find_max_sum(arr_A, arr_B, no_of_swaps):
	ind = 0
	while ind < no_of_swaps:
		if arr_A[ind] >= arr_B[ind]:
			return sum(arr_A)
		else:
			arr_A[ind] = arr_B[ind]
			ind += 1
	return sum(arr_A)
for i in range(test_cases):
	(arr_size, no_of_swaps) = map(int, input().split(' '))
	arr_A = list(map(int, input().split(' ')))
	arr_B = list(map(int, input().split(' ')))
	arr_A.sort()
	arr_B = sorted(arr_B)[::-1]
	print(find_max_sum(arr_A, arr_B, no_of_swaps))


from heapq import heappush, heappop, heapreplace

def maxSwap(a, b, k):
	(aHeap, bHeap) = ([], [])
	for n in a:
		heappush(aHeap, n)
	for n in b:
		heappush(bHeap, -n)
	while k and aHeap[0] < -bHeap[0]:
		heapreplace(aHeap, -heappop(bHeap))
		k -= 1
	return sum(aHeap)

def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(maxSwap(a, b, k))
for _ in range(int(input())):
	solve()


t = int(input())
for k in range(t):
	(a, b) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	l2 = l2[::-1]
	ar = []
	val = 0
	for i in range(a):
		if i + 1 <= b:
			if l2[i] > l1[i]:
				ar.append(l2[i])
				val += l2[i]
			else:
				ar.append(l1[i])
				val += l1[i]
		else:
			ar.append(l1[i])
			val += l1[i]
	print(val)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	while i < n and j >= 0 and (k > 0):
		if a[i] < b[j]:
			a[i] = b[j]
			i += 1
			j -= 1
			k -= 1
		else:
			break
	print(sum(a))
	t -= 1


from collections import Counter
import math
mod = 10 ** 9 + 7
for i in range(int(input())):
	(n, k) = map(int, input().split())
	arr1 = [int(i) for i in input().split()]
	arr2 = [int(i) for i in input().split()]
	arr1.sort()
	arr2.sort(reverse=True)
	x = sum(arr1)
	for i in range(k):
		if arr2[i] > arr1[i]:
			x += abs(arr2[i] - arr1[i])
	print(x)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	b = b[::-1]
	s = sum(a)
	for i in range(n):
		if a[i] < b[i] and k > 0:
			s += b[i] - a[i]
			k -= 1
	print(s)


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for _ in range(k):
		tmpA = min(a)
		tmpB = max(b)
		if tmpA < tmpB:
			a[a.index(tmpA)] = tmpB
			b[b.index(tmpB)] = tmpA
	print(sum(a))


t = int(input())
count = 0
final = []
while count < t:
	info = input()
	(size, move) = info.split(' ')
	a = input()
	a = [int(x) for x in a.split(' ')]
	b = input()
	b = [int(x) for x in b.split(' ')]
	a = sorted(a)
	b = sorted(b)
	count2 = 0
	while int(move) != 0:
		if a[count2] < b[-1 - count2]:
			a[count2] = b[-1 - count2]
			count2 += 1
			move = int(move) - 1
		else:
			move = 0
			break
	total = 0
	for x in a:
		total += x
	final.append(total)
	count += 1
for x in final:
	print(x)


t = int(input())
output = []
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	count = total = 0
	(i, j) = (0, n - 1)
	while i < n and j >= 0 and (count < k):
		if a[i] < b[j]:
			a[i] = b[j]
			count += 1
			i += 1
			j -= 1
		else:
			break
	total = sum(a)
	output.append(total)
for i in output:
	print(i)


tc = input()
for _ in range(int(tc)):
	i = input().split()
	a = int(i[0])
	b = int(i[1])
	k = input().split()
	j = input().split()
	for i in range(len(k)):
		k[i] = int(k[i])
		j[i] = int(j[i])
	count = 0
	k.sort()
	j.sort(reverse=True)
	for i in range(a):
		if i < b:
			if int(j[i]) > int(k[i]):
				count += int(j[i])
			else:
				count += int(k[i])
		else:
			count += int(k[i])
	print(str(count) + '\n')


def main():
	t = int(input())
	for _ in range(t):
		nk = input().split()
		n = nk[0]
		k = int(nk[1])
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		s = sum(a)
		i = 0
		while i < k:
			if min(a) < max(b):
				a[a.index(min(a))] = max(b)
				b[b.index(max(b))] = min(a)
			i += 1
			if sum(a) > s:
				s = sum(a)
		print(s)
main()


for i in range(int(input())):
	(a, b) = map(int, input().split())
	sp = list(map(int, input().split()))
	sp2 = list(map(int, input().split()))
	for j in range(b):
		(c, d) = (min(sp), max(sp2))
		if c >= d:
			break
		else:
			(sp[sp.index(c)], sp2[sp2.index(d)]) = (sp2[sp2.index(d)], sp[sp.index(c)])
	print(sum(sp))


T = int(input())
for _ in range(0, T):
	(n, k) = map(int, input().split())
	s1 = [int(x) for x in input().split()]
	s2 = [int(x) for x in input().split()]
	s1.sort()
	s2.sort()
	s2 = s2[::-1]
	ans = 0
	for i in range(0, len(s1)):
		ans += s1[i]
	for i in range(k):
		if s1[i] < s2[i]:
			ans = ans - s1[i] + s2[i]
		else:
			break
	print(ans)


test = int(input())
for _ in range(test):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	inda = 0
	indb = 0
	move = 0
	for i in range(n):
		if move >= k:
			break
		if a[inda] < b[indb]:
			(a[inda], b[indb]) = (b[indb], a[inda])
			inda += 1
			indb += 1
			move += 1
		else:
			break
	print(sum(a))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	aa = [0 for _ in range(31)]
	bb = [0 for _ in range(31)]
	av = n
	for j in a:
		aa[j] += 1
	for j in b:
		bb[j] += 1
	s = a + b
	s.sort()
	ch = k
	ans = 0
	lenn = 0
	for i in range(len(s) - 1, -1, -1):
		now = s[i]
		if lenn < len(a):
			if aa[now] > 0:
				ans += now
				aa[now] -= 1
				lenn += 1
			elif ch - 1 >= 0:
				ch -= 1
				ans += now
				lenn += 1
	print(ans)


TEST = int(input())
answers = []
for _ in range(TEST):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	i = 0
	while k > 0:
		if a[i] > b[i]:
			break
		(a[i], b[i]) = (b[i], a[i])
		i += 1
		k -= 1
	answers.append(sum(a))
for ans in answers:
	print(ans)


test_cases = int(input(''))
for _ in range(test_cases):
	(n, k) = map(int, input().split(' '))
	a = sorted(list(map(int, input().split(' '))))
	b = sorted(list(map(int, input().split(' '))))
	i = 0
	while k and i < len(a):
		if a[i] > b[-i - 1]:
			break
		(a[i], b[-i - 1]) = (b[-i - 1], a[i])
		i += 1
		k -= 1
	print(sum(a))
	print('', '')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort(reverse=True)
	s = 0
	l3 = l1[:k] + l2[:k]
	l3.sort()
	print(sum(l3[-k:] + l1[k:]))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	for j in range(k):
		mx = 0
		mn = 10 ** 20
		mxi = 0
		mni = 0
		for i in range(n):
			if A[i] < mn:
				mn = A[i]
				mni = i
			if B[i] > mx:
				mx = B[i]
				mxi = i
		if A[mni] > B[mxi]:
			break
		(A[mni], B[mxi]) = (B[mxi], A[mni])
	r = sum(A)
	print(r)


n = int(input())
for i in range(n):
	c = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort()
	b.reverse()
	count = 0
	for j in range(len(a)):
		if a[j] < b[j] and c[1] > 0:
			(a[j], b[j]) = (b[j], a[j])
			count += 1
		if count == c[1]:
			print(sum(a))
			break
		elif count == 0:
			print(sum(a))
			break
		elif count > 0 and j == len(a) - 1:
			print(sum(a))
			break


T = int(input())
while T:
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort(reverse=True)
	S = 0
	for i in range(k):
		S = S + max(A[i], B[i])
	S = S + sum(A[k:])
	print(S)
	T = T - 1


t = int(input())
import math
output = []
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	a.reverse()
	b.sort()
	b.reverse()
	for i in range(k):
		if b[i] > a[-i - 1]:
			a[-i - 1] = b[i]
	output.append(sum(a))
for item in output:
	print(item)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	x = list(map(int, input().split()))
	l.sort()
	x.sort(reverse=True)
	i = 0
	z = 0
	j = 0
	while z < k and i < n:
		if l[i] < x[j]:
			l[i] = x[j]
			i = i + 1
			j = j + 1
			z = z + 1
		else:
			i = i + 1
	print(sum(l))


test_cases = int(input())
while test_cases > 0:
	(num, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	sum = 0
	swap = 0
	j = 0
	for i in range(0, num):
		if a[i] < b[j] and swap < k:
			swap += 1
			a[i] = b[j]
			j += 1
	for element in a:
		sum += element
	print(sum)
	test_cases -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	i = 0
	j = n - 1
	while k > 0 and i < n and (j >= 0):
		if a[i] < b[j]:
			temp = b[j]
			b[j] = a[i]
			a[i] = temp
			j -= 1
			i += 1
			k -= 1
		else:
			break
	total = 0
	for x in a:
		total += x
	print(total)


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, key=lambda x: -x)
	s = 0
	for i in range(k):
		s_new = s + b[i] - a[i]
		if s_new < s:
			break
		s = s_new
	print(s + sum(a))
n = int(input())
for _ in range(n):
	solve()


testcases = int(input())
for case in range(testcases):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	sumA = sum(a)
	b = sorted(map(int, input().split()))
	i = 0
	while k > 0 and i < len(a):
		if a[i] < b[-1 - i]:
			k = k - 1
			sumA = sumA - a[i] + b[-1 - i]
			i = i + 1
		else:
			break
	print(sumA)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(o) for o in input().split()]
	b = [int(o) for o in input().split()]
	a.sort()
	b.sort()
	b = b[::-1]
	for i in range(k):
		if b[i] > a[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


for xyz in range(0, int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	d = []
	sd = 0
	for i in range(0, n):
		if b[i] > a[i]:
			d.append(b[i] - a[i])
			sd += 1
	d.sort(reverse=True)
	if sd > k:
		print(sum(a) + sum(d[0:k]))
	else:
		print(sum(a) + sum(d))


t = int(input())
ans = []
for i in range(t):
	(n, k) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	s1.sort()
	s2.sort(reverse=True)
	for i in range(k):
		if s1[i] < s2[i]:
			(s1[i], s2[i]) = (s2[i], s1[i])
	ans.append(sum(s1))
for i in ans:
	print(i)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = []
	x = input().split()
	for i in x:
		a.append(int(i))
	b = []
	x = input().split()
	for i in x:
		b.append(int(i))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	count = 0
	while count < k and a[i] < b[j]:
		a[i] = b[j]
		count += 1
		i += 1
		j -= 1
	print(sum(a))
	t -= 1


def qb(a, b, n, k):
	a = sorted(a)
	b = sorted(b)
	amin = a[0]
	bmax = b[n - 1]
	ano = 0
	bno = n - 1
	while k > 0 and ano <= n and (bno >= 0) and (amin < bmax):
		(a[ano], b[bno]) = (b[bno], a[ano])
		k -= 1
		ano += 1 if ano < n - 1 else 0
		bno -= 1 if bno > 0 else 0
		amin = a[ano]
		bmax = b[bno]
	return sum(a)
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(qb(a, b, n, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	liA = list(map(int, input().split()))
	liB = list(map(int, input().split()))
	liB.sort(reverse=True)
	liA += liB[:k]
	liA.sort(reverse=True)
	print(sum(liA[:n]))


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
from math import gcd
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
t = inp(1)
while t:
	t -= 1
	(n, k) = inp()
	a = inp()
	b = inp()
	a = sorted(a)
	b = sorted(b, reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))


import sys
import bisect
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

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

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

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

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(ri())):
	(n, k) = Ri()
	a = Ri()
	b = Ri()
	a.sort()
	b.sort(reverse=True)
	itea = 0
	iteb = 0
	while k > 0:
		if a[itea] < b[iteb]:
			a[itea] = b[iteb]
			k -= 1
			itea += 1
			iteb += 1
		else:
			break
	print(sum(a))


from collections import defaultdict, deque
import heapq, bisect, math, itertools, string, queue, copy, time
import sys
input = sys.stdin.readline
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

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

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

def inpl_str():
	return list(input().split())
ans = []
t = inp()
for i in range(t):
	(n, k) = inpl()
	a = inpl()
	b = inpl()
	b.sort(reverse=True)
	a.extend(b[:k])
	a.sort(reverse=True)
	ans.append(sum(a[:n]))
for i in ans:
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(sorted(map(int, input().split())))
	b = list(sorted(map(int, input().split()), reverse=True))
	pivo = 0
	soma = 0
	for i in range(n):
		if pivo == k:
			soma += sum(a[i:])
			break
		if a[i] >= b[pivo]:
			soma += a[i]
		else:
			soma += b[pivo]
			pivo += 1
	print(soma)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	c = sum(a)
	d = sum(b)
	e = sorted(a)
	f = sorted(b)
	g = f[::-1]
	for i in range(k):
		if e[i] < g[i]:
			c = c - e[i]
			c = c + g[i]
	print(c)


def solve(a, b, k):
	total = sum(a)
	for i in range(0, k):
		if b[i] > a[i]:
			total += b[i] - a[i]
		else:
			break
	return total
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	print(solve(a, b, k))


n = int(input())
for _ in range(n):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	x = 0
	y = len(b) - 1
	for _ in range(k):
		if a[x] < b[y]:
			a[x] = b[y]
			x += 1
			y -= 1
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr = sorted(arr)
	brr = sorted(brr)
	j = n - 1
	for i in range(k):
		if arr[i] < brr[j]:
			arr[i] = brr[j]
			j -= 1
		else:
			break
	print(sum(arr))


tests = int(input())
for test in range(tests):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	a += b[:k]
	a.sort(reverse=True)
	print(sum(a[:n]))


t = int(input())
from collections import defaultdict
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ap = 0
	bp = 0
	while bp < k:
		if a[ap] < b[bp]:
			a[ap] = b[bp]
			ap += 1
			bp += 1
		else:
			break
	print(sum(a))


for ii in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	temp1 = sorted(a)
	temp2 = sorted(b, reverse=True)
	for i in range(k):
		if temp1[i] < temp2[i]:
			(temp1[i], temp2[i]) = (temp2[i], temp1[i])
	print(sum(temp1))


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for _ in range(k):
		if min(a) < max(b):
			a[a.index(min(a))] = max(b)
			b.remove(max(b))
		else:
			break
	sums = 0
	for v in a:
		sums += v
	print(sums)


import sys
sys.setrecursionlimit(10 ** 8)
try:
	FILE_POINTER = open('input.inpt')
	input = FILE_POINTER.readline
except:
	FILE_POINTER = None
	input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	while k:
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			i += 1
			j -= 1
			k -= 1
		else:
			break
	print(sum(a))
if FILE_POINTER:
	FILE_POINTER.close()


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ans = 0
	for i in range(n):
		if i < k:
			ans += max(a[i], b[i])
		else:
			ans += a[i]
	return ans
t = int(input())
for i in range(t):
	print(main())


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


t = int(input())
list_new = []
for i in range(0, t):
	list0 = [int(k) for k in input().split()]
	list_a = [int(i) for i in input().split()]
	list_b = [int(j) for j in input().split()]
	n = list0[0]
	k = list0[1]
	for i in range(0, k):
		a1 = list_a.index(min(list_a))
		b1 = list_b.index(max(list_b))
		if min(list_a) <= max(list_b):
			(list_b[b1], list_a[a1]) = (list_a[a1], list_b[b1])
	sum = 0
	for i in list_a:
		sum += i
	list_new.append(sum)
for i in list_new:
	print(i)


def compute(n, k, a, b):
	sum1 = sum(a)
	sum2 = sum(b)
	a.sort()
	b.sort(reverse=True)
	a_index = 0
	b_index = 0
	for _ in range(k):
		if a[a_index] < b[b_index]:
			a[a_index] = b[b_index]
			a_index += 1
			b_index += 1
		else:
			b_index += 1
	return sum(a)
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(compute(n, k, a, b))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	li1 = list(map(int, input().split()))
	li.sort()
	li1.sort()
	ans = sum(li)
	for i in range(k):
		if li[i] < li1[n - 1 - i]:
			ans += li1[n - 1 - i] - li[i]
		else:
			break
	print(ans)


n = int(input())
for i in range(n):
	(l, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sum = 0
	h = 0
	while m != 0 and h != l:
		h += 1
		if max(a) >= max(b):
			sum += max(a)
			a.remove(max(a))
		else:
			sum += max(b)
			m -= 1
			b.remove(max(b))
	while h != l:
		sum += max(a)
		a.remove(max(a))
		h += 1
	print(sum)


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby

def Golf():
	(*a,) = map(int, open(0))

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

def S_():
	return input()

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

def LS():
	return [i for i in input().split()]

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in range(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def bit_combination(n, base=2):
	rt = []
	for tb in range(base ** n):
		s = [tb // base ** bt % base for bt in range(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['YES', 'NO']
Yn = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(1, 0), (-1, 0), (0, 1), (0, -1)]
EightNb = [(1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('EWNS', FourNb))
l_alp = string.ascii_lowercase
input = lambda : sys.stdin.readline().rstrip()

class Tree:

	def __init__(self, inp_size=None, ls=None, init=True, index=0):
		self.LCA_init_stat = False
		self.ETtable = []
		if init:
			if ls == None:
				self.stdin(inp_size, index=index)
			else:
				self.size = len(ls) + 1
				(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def stdin(self, inp_size=None, index=1):
		if inp_size == None:
			self.size = int(input())
		else:
			self.size = inp_size
		(self.edges, _) = GI(self.size, self.size - 1, index=index)
		return

	def listin(self, ls, index=0):
		self.size = len(ls) + 1
		(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def __str__(self):
		return str(self.edges)

	def dfs(self, x, func=lambda prv, nx, dist: prv + dist, root_v=0):
		q = deque()
		q.append(x)
		v = [-1] * self.size
		v[x] = root_v
		while q:
			c = q.pop()
			for (nb, d) in self.edges[c]:
				if v[nb] == -1:
					q.append(nb)
					v[nb] = func(v[c], nb, d)
		return v

	def EulerTour(self, x):
		q = deque()
		q.append(x)
		self.depth = [None] * self.size
		self.depth[x] = 0
		self.ETtable = []
		self.ETdepth = []
		self.ETin = [-1] * self.size
		self.ETout = [-1] * self.size
		cnt = 0
		while q:
			c = q.pop()
			if c < 0:
				ce = ~c
			else:
				ce = c
				for (nb, d) in self.edges[ce]:
					if self.depth[nb] == None:
						q.append(~ce)
						q.append(nb)
						self.depth[nb] = self.depth[ce] + 1
			self.ETtable.append(ce)
			self.ETdepth.append(self.depth[ce])
			if self.ETin[ce] == -1:
				self.ETin[ce] = cnt
			else:
				self.ETout[ce] = cnt
			cnt += 1
		return

	def LCA_init(self, root):
		self.EulerTour(root)
		self.st = SparseTable(self.ETdepth, init_func=min, init_idl=inf)
		self.LCA_init_stat = True
		return

	def LCA(self, root, x, y):
		if self.LCA_init_stat == False:
			self.LCA_init(root)
		(xin, xout) = (self.ETin[x], self.ETout[x])
		(yin, yout) = (self.ETin[y], self.ETout[y])
		a = min(xin, yin)
		b = max(xout, yout, xin, yin)
		id_of_min_dep_in_et = self.st.query_id(a, b + 1)
		return self.ETtable[id_of_min_dep_in_et]

class SparseTable:

	def __init__(self, ls, init_func=min, init_idl=float('inf')):
		self.func = init_func
		self.idl = init_idl
		self.size = len(ls)
		self.N0 = self.size.bit_length()
		self.table = [ls[:]]
		self.index = [list(range(self.size))]
		self.lg = [0] * (self.size + 1)
		for i in range(2, self.size + 1):
			self.lg[i] = self.lg[i >> 1] + 1
		for i in range(self.N0):
			tmp = [self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) for j in range(self.size)]
			tmp_id = [self.index[i][j] if self.table[i][j] == self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) else self.index[i][min(j + (1 << i), self.size - 1)] for j in range(self.size)]
			self.table += [tmp]
			self.index += [tmp_id]

	def query(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		return self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))])

	def query_id(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		(a, b) = (self.index[N][l], self.index[N][max(0, r - (1 << N))])
		if self.table[0][a] == self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))]):
			b = a
		return b

	def __str__(self):
		return str(self.table[0])

	def print(self):
		for i in self.table:
			print(*i)

class Comb:

	def __init__(self, n, mo=10 ** 9 + 7):
		self.fac = [0] * (n + 1)
		self.inv = [1] * (n + 1)
		self.fac[0] = 1
		self.fact(n)
		for i in range(1, n + 1):
			self.fac[i] = i * self.fac[i - 1] % mo
			self.inv[n] *= i
			self.inv[n] %= mo
		self.inv[n] = pow(self.inv[n], mo - 2, mo)
		for i in range(1, n):
			self.inv[n - i] = self.inv[n - i + 1] * (n - i + 1) % mo
		return

	def fact(self, n):
		return self.fac[n]

	def invf(self, n):
		return self.inv[n]

	def comb(self, x, y):
		if y < 0 or y > x:
			return 0
		return self.fac[x] * self.inv[x - y] * self.inv[y] % mo
show_flg = False
show_flg = True
ans = 0
T = I()
for _ in range(T):
	ans = 0
	(n, k) = LI()
	a = LI()
	b = [-i for i in LI()]
	heapify(a)
	heapify(b)
	for i in range(k):
		if a[0] > -b[0]:
			break
		A = heappop(a)
		B = -heappop(b)
		heappush(a, B)
		heappush(b, -A)
	ans = sum(a)
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	p1 = 0
	p2 = n - 1
	for i in range(k):
		if a[p1] > b[p2]:
			break
		(a[p1], b[p2]) = (b[p2], a[p1])
		p1 += 1
		p2 -= 1
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = [(a[i], 'a') for i in range(n)]
	b = [(b[i], 'b') for i in range(n)]
	test = a + b
	test.sort(reverse=True)
	ans = 0
	count = 0
	count2 = 0
	for i in range(2 * n):
		(val, str) = test[i]
		if count == k:
			if str == 'a':
				ans += val
				count2 += 1
		elif str == 'a':
			ans += val
			count2 += 1
		else:
			ans += val
			count += 1
			count2 += 1
		if count2 == n:
			break
	print(ans)


def max_sum(a, b, k):
	n = len(a)
	A = sorted(a)
	B = sorted(b, reverse=True)
	for i in range(k):
		if B[i] > A[i]:
			(A[i], B[i]) = (B[i], A[i])
	return sum(A)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(max_sum(a, b, k))


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()])
	ans = sum(a)
	for i in range(1, k + 1):
		ans = max((ans, sum(a[i:] + b[n - i:])))
	print(ans)


t = int(input())
for nm in range(t):
	(num, kswap) = map(int, input().split())
	alist = list(map(int, input().split()))
	blist = list(map(int, input().split()))
	alist.sort()
	blist.sort()
	i = 0
	j = num - 1
	while kswap:
		if alist[i] >= blist[j]:
			break
		else:
			alist[i] = blist[j]
		i += 1
		j -= 1
		kswap -= 1
	sum1 = 0
	for i in range(0, num):
		sum1 += alist[i]
	print(sum1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	b.reverse()
	i = 0
	while k > 0:
		if a[i] <= b[i]:
			(a[i], b[i]) = (b[i], a[i])
			i += 1
		else:
			i += 1
		k -= 1
	print(sum(a))


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	a1.sort()
	a2.sort()
	if a1[0] >= a2[-1]:
		print(sum(a1))
	else:
		for j in range(k):
			if a1[0] < a2[-1]:
				temp = a1[0]
				a1[0] = a2[-1]
				a2[-1] = temp
				a1.sort()
				a2.sort()
		print(sum(a1))


x = []
for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k != 0 and min(a) < max(b):
		min_a = min(a)
		a[a.index(min_a)] = max(b)
		b[b.index(max(b))] = min_a
		k -= 1
	x.append(sum(a))
for e in x:
	print(e)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	topb = sorted(b, reverse=True)[:k]
	print(sum(sorted(a + topb, reverse=True)[:n]))


def who(k, a, b):
	for i in range(k):
		if max(b) >= min(a):
			a[a.index(min(a))] = b[b.index(max(b))]
			b[b.index(max(b))] = 0
	return sum(a)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(who(k, a, b))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for _ in range(k):
		if min(a) < max(b):
			tmp = a[a.index(min(a))]
			a[a.index(min(a))] = b[b.index(max(b))]
			b[b.index(max(b))] = tmp
	print(sum(a))


T = int(input())
for tc in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < k and b[i] > a[i]:
		i += 1
	c = b[:i] + a[i:]
	print(sum(c))


Test = int(input())
while Test > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.insert(0, -1)
	b.insert(0, -1)
	a.sort()
	b.sort()
	i = 1
	j = n
	while k > 0:
		if a[i] < b[j]:
			a.pop(i)
			a.insert(i, b[j])
		i += 1
		j -= 1
		k -= 1
	a.pop(0)
	print(sum(a))
	Test -= 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:n]
	a.sort()
	b.sort()
	x = 0
	y = n - 1
	temp = 0
	while k > 0:
		if b[y] > a[x]:
			temp = a[x]
			a[x] = b[y]
			b[y] = temp
		x += 1
		y -= 1
		k -= 1
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()))
	b.reverse()
	maxSoFar = b[-1]
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))


from sys import stdin
from math import sqrt
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()), reverse=True)
	s = 0
	j = 0
	for i in range(k):
		s = b[j]
		if min(a) < s:
			a[a.index(min(a))] = s
			j += 1
	print(sum(a))


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
from random import randint

def get_int():
	return int(stdin.readline().strip())

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

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

def main():
	(n, k) = get_tuple()
	a = get_list()
	b = get_list()
	a.sort()
	b.sort(reverse=True)
	i = 0
	j = 0
	while k > 0:
		while j < n and b[j] <= a[i]:
			j += 1
		if j < n:
			(a[i], b[j]) = (b[j], a[i])
			j += 1
			i += 1
		else:
			break
		k -= 1
	print(sum(a))
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
for _ in range(ii()):
	(n, k) = f()
	a = il()
	b = il()
	a.sort()
	b.sort(reverse=True)
	for i in range(0, k):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	s = 0
	while k > 0:
		if a[s] < b[n - 1]:
			a[s] = b[n - 1]
			n -= 1
			s += 1
			k -= 1
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	A.sort()
	B.sort(reverse=True)
	for i in range(K):
		if A[i] < B[i]:
			A[i] = B[i]
	print(sum(A))


import sys

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

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
for _ in range(int(input())):
	(n, k) = get_ints()
	a = get_array()
	b = get_array()
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))


def main():
	T = int(input())
	for _ in range(T):
		(N, K) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a = sorted(a)
		b = sorted(b)
		gain = 0
		for k in range(K):
			if a[k] < b[-1 - k]:
				gain += b[-1 - k] - a[k]
			else:
				break
		print(sum(a) + gain)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	array1 = sorted(list(map(int, input().split())), reverse=True)
	array2 = sorted(list(map(int, input().split())))
	sumV = 0
	t = k
	while array2[-1] > array1[-1] and t > 0:
		(array1[-1], array2[-1]) = (array2[-1], array1[-1])
		array1.sort(reverse=True)
		array2.sort()
		t -= 1
	print(sum(array1))


def func():
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	i = 0
	j = n - 1
	while i < k and a[i] < b[j]:
		(a[i], b[j]) = (b[j], a[i])
		i += 1
		j -= 1
	return sum(a)
for _ in range(int(input())):
	print(func())


def swaps():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split(' '))
		a = list(map(int, input().split(' ')))
		b = list(map(int, input().split(' ')))
		a.sort()
		b.sort()
		counter = 0
		counterK = 0
		soma = 0
		while k != 0 and counter < len(a):
			soma += a[counter]
			if a[counter] < b[len(b) - 1 - counterK]:
				soma -= a[counter]
				a[counter] = b[len(b) - 1 - counterK]
				soma += a[counter]
				k -= 1
				counterK += 1
			counter += 1
		while counter < len(a):
			soma += a[counter]
			counter += 1
		print(soma)
swaps()


def main(a, b, n, k):
	a = sorted(a)
	b = sorted(b)
	counter = 0
	index = 0
	while counter < k:
		if a[index] < b[-(index + 1)]:
			a[index] = b[-(index + 1)]
			counter += 1
			index += 1
		else:
			break
	return sum(a)
t = int(input())
out_list = []
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	out_list.append(main(a, b, n, k))
for num in out_list:
	print(num)


ans = []
for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort()
	a.sort()
	s = sum(a)
	for i in range(k):
		bb = max(b)
		aa = min(a)
		if bb > aa:
			s -= aa
			s += bb
			b.remove(bb)
			a.remove(aa)
	ans += [s]
for i in ans:
	print(i)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(n):
		if a[i] >= b[i] or k == 0:
			break
		(a[i], b[i]) = (b[i], a[i])
		k -= 1
	print(sum(a))


T = int(input())
for _ in range(T):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = input().split()
	b = input().split()
	for i in range(n):
		a[i] = int(a[i])
		b[i] = int(b[i])
	a.sort()
	b.sort()
	total = sum(a)
	for i in range(k):
		if a[i] < b[-i - 1]:
			total -= a[i]
			total += b[-i - 1]
	print(total)


t = int(input())
a = list()
b = list()
x = list()
new = list()
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:n]
	p = k
	temp = 0
	for i in range(n):
		if min(a) < max(b) and p > 0:
			m = a.index(min(a))
			l = b.index(max(b))
			temp = a[m]
			a[m] = b[l]
			b[l] = temp
			p = p - 1
	new.append(sum(a))
for i in range(len(new)):
	print(new[i])


test = int(input())
respostas = []
for x in range(test):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k != 0:
		c = a.index(min(a))
		z = b.index(max(b))
		if a[c] < b[z]:
			(a[c], b[z]) = (b[z], a[c])
		k -= 1
	respostas.append(sum(a))
for x in respostas:
	print(x)


import heapq
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = [int(num) for num in input().split()]
	B = [-int(num) for num in input().split()]
	heapq.heapify(B)
	heapq.heapify(A)
	for _ in range(k):
		if -B[0] > A[0]:
			heapq.heappushpop(A, -heapq.heappop(B))
		else:
			break
	print(sum(A))


num = int(input())
for _ in range(num):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	a.sort()
	b = [int(i) for i in input().split()]
	b.sort()
	if k > n:
		k = n
	ans = 0
	at = 0
	bt = n - 1
	for i in range(k):
		r = max(a[at], b[bt])
		if r == a[at]:
			break
		else:
			ans += r
			bt -= 1
			at += 1
	for i in range(at, n):
		ans += a[i]
	print(ans)


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	res = 0
	i = 0
	j = len(b) - 1
	while k > 0 and i < len(b) and (j >= 0):
		if a[i] < b[j]:
			temp = a[i]
			a[i] = b[j]
			b[j] = temp
			k -= 1
		else:
			break
		i += 1
		j -= 1
	print(sum(a))
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()))[::-1]
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < k and a[i] < b[i]:
		a[i] = b[i]
		i += 1
	print(sum(a))


import os
import sys
from io import BytesIO, IOBase

def solution(arr, brr, n, k):
	arr.sort()
	brr.sort()
	if k == 0:
		write(sum(arr))
		return
	if arr[0] >= brr[-1]:
		write(sum(arr))
		return
	for i in range(n):
		if k > 0 and arr[i] < brr[n - i - 1]:
			arr[i] = brr[n - i - 1]
			k -= 1
		else:
			break
	write(sum(arr))

def main():
	for _ in range(r_int()):
		(n, k) = r_array()
		arr = r_array()
		brr = r_array()
		solution(arr, brr, n, k)
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 write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

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

def r_int():
	return int(input())
main()


t = int(input())
while t:
	inp1 = list(map(int, input().strip().split()))[:2]
	(n, k) = (inp1[0], inp1[1])
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:n]
	a.sort()
	b1 = sorted(b, reverse=True)
	count = 0
	i = 0
	sum1 = 0
	while count < k and i < n:
		if a[i] < b1[i]:
			sum1 += b1[i]
			count += 1
		else:
			break
		i += 1
	while i < n:
		sum1 += a[i]
		i += 1
	print(sum1)
	t -= 1


for k in range(int(input())):
	(n, u) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = sum(a)
	for j in range(u):
		ans = max(ans, sum(a[j + 1:]) + sum(b[-(j + 1):]))
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr.sort()
	brr.sort()
	l = len(brr) - 1
	an = 0
	for i in range(k):
		if arr[i] < brr[l - i]:
			an += brr[l - i]
		else:
			an += arr[i]
	s = sum(arr[k:])
	an += s
	print(an)


import math
t = int(input())
for _ in range(0, t):
	s = input().split()
	(n, k) = (int(s[0]), int(s[1]))
	a = input().split()
	b = input().split()
	for i in range(0, len(a)):
		a[i] = int(a[i])
		b[i] = int(b[i])
	a.sort()
	b.sort()
	i = 0
	while k > 0 and b[len(b) - 1 - i] > a[i]:
		a[i] = b[len(b) - 1 - i]
		i += 1
		k -= 1
	print(sum(a))


x = int(input())
while x != 0:
	leng = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	k = leng[1]
	while k != 0:
		if max(b) <= min(a):
			break
		else:
			h = b.index(max(b))
			l = a.index(min(a))
			temp = a[l]
			a[l] = b[h]
			b[h] = a[l]
			b.pop(h)
		k = k - 1
	print(sum(a))
	x = x - 1


t = int(input())
while t != 0:
	total = 0
	ele = 0
	l = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	for i in range(0, len(a)):
		if int(a[i]) < int(b[i]) and int(l[1]) != 0:
			a[i] = int(b[i])
			l[1] = int(l[1]) - 1
	while ele < len(a):
		total = total + int(a[ele])
		ele += 1
	print(total)
	t = t - 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	s = 0
	i = 0
	while i < k:
		s += max(a[i], b[i])
		i += 1
	s += sum(a[i:])
	print(s)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if min(a) >= max(b):
		print(sum(a))
	else:
		for i in range(k):
			(l1, l2) = (min(a), max(b))
			if l1 > l2:
				break
			else:
				(t1, t2) = (a.index(l1), b.index(l2))
				temp = a[t1]
				a[t1] = b[t2]
				b[t2] = temp
		print(sum(a))


t = int(input())
while t:
	t -= 1
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sorted_a = sorted(a)
	sorted_b = sorted(b)
	p = len(sorted_b) - 1
	while k:
		if sorted_a[n - 1 - p] < sorted_b[p]:
			sorted_a[n - 1 - p] = sorted_b[p]
			p -= 1
			k -= 1
		else:
			break
	print(sum(sorted_a))


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	i = 0
	while k > 0 and a[i] < b[-1 - i]:
		a[i] = b[-1 - i]
		k -= 1
		i += 1
	print(sum(a))


import sys
input = sys.stdin.readline

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

def str_array():
	return input().strip().split()

def lower_letters():
	lowercase = [chr(i) for i in range(97, 97 + 26)]
	return lowercase

def upper_letters():
	uppercase = [chr(i) for i in range(65, 65 + 26)]
	return uppercase
for _ in range(int(input())):
	(n, k) = int_array()
	a = sorted(int_array())
	b = sorted(int_array())
	i = 1
	for _ in range(k):
		if b[-i] > a[0]:
			a[0] = b[-i]
			i += 1
			a = sorted(a)
		else:
			break
	print(sum(a))


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	n1 = list(map(int, input().split()))
	n2 = list(map(int, input().split()))
	n1 = sorted(n1)
	n2 = sorted(n2)
	for i in range(k):
		if n1[i] < n2[n - i - 1]:
			n1[i] = n2[n - 1 - i]
	print(sum(n1))


import heapq
t = int(input())

def solve(n, k, a, b):
	minheapa = a
	heapq.heapify(minheapa)
	b = list(map(lambda x: -x, b))
	maxheapb = b
	heapq.heapify(maxheapb)
	for _ in range(k):
		minval = heapq.heappop(minheapa)
		maxval = heapq.heappop(maxheapb)
		if minval >= -maxval:
			heapq.heappush(minheapa, minval)
			heapq.heappush(maxheapb, maxval)
			break
		heapq.heappush(minheapa, -maxval)
		heapq.heappush(maxheapb, minval)
	total = 0
	for v in minheapa:
		total += v
	return total
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(n, k, a, b))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	l = sum(a)
	for i in range(k):
		(a[i], b[i]) = (b[i], a[i])
		h = sum(a)
		if h > l:
			l = h
	print(l)


class queue:

	def __init__(self, length, config):
		self.length = length
		self.arr = list()
		self.config = config

	def add(self, value):
		if len(self.arr) < self.length:
			index = BinarySearch(self.arr, len(self.arr), value)
			self.arr.insert(index, value)
		elif self.config:
			if self.arr[0] > value:
				return
			else:
				self.arr.pop(0)
				index = BinarySearch(self.arr, len(self.arr), value)
				self.arr.insert(index, value)
		elif self.arr[-1] < value:
			return
		else:
			self.arr.pop()
			index = BinarySearch(self.arr, len(self.arr), value)
			self.arr.insert(index, value)

	def show(self):
		return list(self.arr)

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

def merge(max_list: list(), min_list: list()):
	count = k
	val = -sum(min_list)
	while count:
		if max_list[-1] > min_list[-1]:
			val += max_list.pop()
		else:
			val += min_list.pop()
		count -= 1
	return val
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	queue_min = queue(k, 0)
	queue_max = queue(k, 1)
	ans = 0
	arr = [int(i) for i in input().split()]
	if not k:
		x = input()
		print(sum(arr))
	else:
		for num in arr:
			ans += num
			queue_min.add(num)
		arr = [int(i) for i in input().split()]
		for num in arr:
			queue_max.add(num)
		print(ans + merge(queue_max.show(), queue_min.show()))


x = int(input())
for i in range(x):
	nk = list(map(int, input().split()))
	n = nk[0]
	k = nk[1]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b = sorted(b)[::-1]
	a = sorted(a)
	i = 0
	while b[0] > a[0] and i < k:
		(a[0], b[0]) = (b[0], a[0])
		b = sorted(b)[::-1]
		a = sorted(a)
		i += 1
	print(sum(a))


def solve(a, b, k):
	a.sort()
	b.sort()
	(i, j) = (0, len(b) - 1)
	sum = 0
	while i < len(a) and k > 0 and (a[i] < b[j]):
		sum += b[j]
		i += 1
		j -= 1
		k -= 1
	while i < len(a):
		sum += a[i]
		i += 1
	return sum

def readNums():
	return [int(x) for x in input().split()]
T = int(input())
for i in range(T):
	(n, k) = readNums()
	a = readNums()
	b = readNums()
	print(solve(a, b, k))


def solution(acts, a, b):
	while acts and b:
		if max(b) > min(a):
			a[a.index(min(a))] = b.pop(b.index(max(b)))
			acts -= 1
		else:
			break
	return sum(a)

def main():
	for test in range(int(input())):
		(_, actions) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		print(solution(actions, a, b))
main()


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for _ in range(k):
		min_num_a = min(a)
		max_num_b = max(b)
		if min_num_a < max_num_b:
			a.remove(min_num_a)
			b.remove(max_num_b)
			a.append(max_num_b)
			b.append(min_num_a)
	print(sum(a))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	m = input()
	l1 = sorted([int(i) for i in m.split()])
	n = input()
	l2 = sorted([int(i) for i in n.split()], reverse=True)
	for i in range(b):
		if l1[i] < l2[i]:
			t = 0
			t = l1[i]
			l1[i] = l2[i]
			l2[i] = t
	print(sum(l1))


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	b = b[::-1]
	swaps = 0
	while swaps < k:
		if b[swaps] > a[swaps]:
			(a[swaps], b[swaps]) = (b[swaps], a[swaps])
		swaps += 1
	print(sum(a))


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def solve(a, b, k):
	sorted_a = sorted(a)
	sorted_b = sorted(b, reverse=True)
	for i in range(k):
		if sorted_a[i] < sorted_b[i]:
			sorted_a[i] = sorted_b[i]
		else:
			break
	return str(sum(sorted_a))
answers = []
t = int(input())
for i in range(t):
	(n, k) = to_list(input())
	a = to_list(input())
	b = to_list(input())
	answers.append(solve(a, b, k))
print('\n'.join(answers))


import collections
import math

def sort(key):
	return key[1]

def solve(lst1, lst2, k):
	lst1 = sorted(lst1)
	lst2 = sorted(lst2)
	for i in range(k):
		if len(lst2) > 0:
			p = lst2.pop()
			if p > lst1[i]:
				lst1[i] = p
	return sum(lst1)
k = int(input())
for i in range(k):
	args = list(map(int, input().split()))
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	print(solve(lst1, lst2, args[1]))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	for _ in range(k):
		if min(a) < max(b):
			l.append(max(b))
			i = a.index(min(a))
			z = b.index(max(b))
			a.pop(i)
			b.pop(z)
	res = sum(l) + sum(a)
	print(res)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	c.sort()
	d.sort()
	i = 0
	while b > 0:
		if b > 0 and i > a - 1:
			break
		if c[i] < d[a - 1 - i]:
			(c[i], d[a - 1 - i]) = (d[a - 1 - i], c[i])
		else:
			k = i + 1
			while k < a:
				if c[k] < d[a - 1 - k]:
					(c[k], d[a - 1 - k]) = (d[a - 1 - k], c[k])
					break
				else:
					k += 1
			i = k
		b -= 1
	print(sum(c))


from sys import stdin, stdout, exit as sys_ret
(f_input, f_print, f_flush) = (stdin.readline, stdout.write, stdout.flush)
for _ in range(int(f_input())):
	(amount, steps) = map(int, f_input().split())
	first = sorted([int(i) for i in f_input().split()])
	second = sorted([int(i) for i in f_input().split()], reverse=True)
	answer = 0
	for i in range(amount):
		if i < steps:
			answer += max(first[i], second[i])
		else:
			answer += first[i]
	f_print(str(answer) + '\n')


t = int(input())

def fun(n, k, a, b):
	b.sort()
	a.sort()
	i = 0
	while k > 0 and i < n:
		if a[i] < b[n - 1]:
			(a[i], b[n - 1]) = (b[n - 1], a[i])
			k -= 1
		i += 1
		b.sort()
	print(sum(a))
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	fun(n, k, a, b)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in range(k):
		swap1 = min(a)
		swap2 = max(b)
		if swap1 < swap2:
			a.remove(swap1)
			a.append(swap2)
			b.remove(swap2)
			b.append(swap1)
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if max(b) <= min(a) or k == 0:
		print(sum(a))
	else:
		while k > 0 and max(b) >= min(a):
			p = b.index(max(b))
			q = a.index(min(a))
			a[q] = b[p]
			b.remove(b[p])
			k -= 1
		print(sum(a))


t = input()
t = int(t)
for i in range(0, t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	for j in range(0, k):
		if b[j] > a[j]:
			a[j] = b[j]
	soma = sum(a)
	print(soma)


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(x) for x in input().split()]
	for i in range(k):
		if min(arr1) < max(arr2):
			a = min(arr1)
			b = max(arr2)
			arr1.remove(a)
			arr1.append(b)
			arr2.remove(b)
			arr2.append(a)
	print(sum(arr1))


def calc(a, b, k):
	for i in range(k):
		(idx_min, idx_max) = (0, 0)
		(min_val, max_val) = (a[0], b[0])
		for x in range(1, len(a)):
			if a[x] < min_val:
				idx_min = x
				min_val = a[x]
		for x in range(1, len(b)):
			if b[x] > max_val:
				idx_max = x
				max_val = b[x]
		if a[idx_min] > b[idx_max]:
			return sum(a)
		(a[idx_min], b[idx_max]) = (b[idx_max], a[idx_min])
	return sum(a)
t = int(input())
for i in range(t):
	(x, k) = list(map(int, input().split()))
	n = list(map(int, input().split()))
	m = list(map(int, input().split()))
	print(calc(n, m, k))


for i in range(int(input())):
	a = list(map(int, input().strip().split()))[:2]
	b = list(map(int, input().strip().split()))[:a[0]]
	c = list(map(int, input().strip().split()))[:a[0]]
	b.sort()
	c.sort()
	c.reverse()
	j = 0
	while a[1] > 0:
		if c[j] > b[j]:
			b[j] = c[j]
		j += 1
		a[1] -= 1
	sum = 0
	for k in b:
		sum += k
	print(sum)


from collections import Counter
t = int(input())
while t > 0:
	t = t - 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if max(b) <= min(a):
		print(sum(a))
	else:
		a.sort()
		b.sort()
		for i in range(k):
			if a[i] < b[-1 - i]:
				a[i] = b[-1 - i]
			else:
				break
		print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	b.sort()
	a.sort(reverse=True)
	s = 0
	for j in range(1, k + 1):
		if b[-j] - a[-j] > 0:
			s += b[-j] - a[-j]
	print(sum(a) + s)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	i = 0
	while i < k:
		if a[i] > b[i]:
			break
		(a[i], b[i]) = (b[i], a[i])
		i += 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = [int(a) for a in input().split()]
	list1 = [int(a) for a in input().split()]
	list2 = [int(a) for a in input().split()]
	list1.sort()
	list2.sort()
	list2.reverse()
	sum1 = 0
	count = 0
	for x in range(n):
		if count < k:
			if list1[x] < list2[x]:
				sum1 = sum1 + list2[x]
				count = count + 1
			else:
				sum1 = sum1 + list1[x]
		elif count >= k:
			sum1 = sum1 + list1[x]
	print(sum1)


def solution(t):
	for _ in range(t):
		nk = input().split()
		(n, k) = (int(nk[0]), int(nk[1]))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if k == 0:
			print(sum(a))
		else:
			a.sort()
			b.sort()
			cnt = 0
			for i in range(k):
				if b[-1 - i] > a[0 + i]:
					cnt += 1
				else:
					break
			print(sum(a[cnt:]) + sum(b[n - cnt:]))
solution(int(input()))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	a.sort()
	sum = 0
	for i in range(n):
		if k > 0:
			sum += max(a[i], b[i])
			k -= 1
		else:
			sum += a[i]
	print(sum)


def solve():
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	if k == 0:
		print(sum(a))
	else:
		print(sum(sorted(a + sorted(b)[-k:])[-n:]))
t = int(input())
for tc in range(t):
	solve()


t = int(input())
i = 0
c = []
while i < t:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	B = []
	b.reverse()
	j = 0
	while j < k:
		B.append(b[j])
		j += 1
	A = []
	l = 0
	z = []
	z = a + B
	z.sort()
	z.reverse()
	a.sort()
	while l < n:
		A.append(z[l])
		l += 1
	c.append(sum(A))
	i += 1
for x in c:
	print(x)


import math
import collections
from sys import stdin, stdout
import bisect as bs
T = int(stdin.readline())
for _ in range(T):
	(n, k) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	a.sort()
	b.sort(reverse=True)
	ans = sum(a)
	m = 0
	for i in range(n):
		if a[i] >= b[i]:
			break
		if m + 1 <= k:
			ans += b[i] - a[i]
			m += 1
	print(ans)


a = int(input())
for i in range(0, a):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr.sort()
	brr.sort()
	for i in range(0, k):
		arr.sort()
		brr.sort()
		if arr[0] < brr[len(brr) - 1]:
			(arr[0], brr[len(brr) - 1]) = (brr[len(brr) - 1], arr[0])
	print(sum(arr))


t = int(input())
while t != 0:
	t -= 1
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	(i, cnt) = (0, 0)
	while i < n and cnt < k:
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
			cnt += 1
		i += 1
	print(sum(a))


s = input()
while True:
	try:
		s1 = list(map(int, input().split(' ')))
		s2 = sorted(list(map(int, input().split(' '))))
		s3 = sorted(list(map(int, input().split(' '))))
		for i in range(s1[1]):
			if s2[i] < s3[len(s3) - 1 - i]:
				s2[i] = s3[len(s3) - 1 - i]
		print(sum(s2))
	except:
		break


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	su = 0
	for i in range(n):
		if i < k:
			if a[i] < b[i]:
				su += b[i]
			else:
				su += a[i]
		elif i >= k:
			su += a[i]
	print(su)


x = int(input())
for _ in range(x):
	(_, swaps) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(swaps):
		if min(a) < max(b):
			a.remove(min(a))
			a.append(max(b))
			b.remove(max(b))
		else:
			break
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort()
	cursum = 0
	for i in range(k):
		if a[i] < b[n - 1 - i]:
			cursum += b[n - 1 - i]
		else:
			cursum += a[i]
	for i in range(k, n):
		cursum += a[i]
	print(cursum)


def solve():
	size_swaps = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	swaps = 0
	index = 0
	for elem in a:
		if swaps < size_swaps[1]:
			if elem < b[index]:
				a[index] = b[index]
				index += 1
				swaps += 1
	print(sum(a))

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


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort(reverse=True)
	for i in range(n):
		if l1[i] < l2[i] and k > 0:
			(l1[i], l2[i]) = (l2[i], l1[i])
			k = k - 1
		else:
			break
	print(sum(l1))


t = int(input())
for _ in range(t):
	(n, lim) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	while lim > 0:
		lim -= 1
		a_min = min(a)
		b_max = max(b)
		if a_min < b_max:
			a[a.index(a_min)] = b_max
			b.remove(b_max)
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = input().split()
	b = input().split()
	for i in range(n):
		a[i] = int(a[i])
		b[i] = int(b[i])
	a = sorted(a)
	b = sorted(b)
	i = 0
	for _ in range(k):
		if b[n - 1 - i] > a[i]:
			a[i] = b[n - 1 - i]
			i += 1
		else:
			break
	tmp = 0
	for x in a:
		tmp += x
	print(tmp)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	s = 0
	for i in range(n):
		if l1[i] > l2[n - i - 1] or k == 0:
			s += l1[i]
		else:
			s += l2[n - i - 1]
			k -= 1
	print(s)


import math
from sys import stdin, stdout
from heapq import heapify, heappop, heappush
from collections import Counter
T = int(stdin.readline())
for i in range(T):
	(N, K) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	heapify(a)
	mx = list(map(lambda x: -x, b))
	heapify(mx)
	f = 0
	while K > 0:
		e1 = -heappop(mx)
		e2 = heappop(a)
		if e1 <= e2:
			print(sum(a) + e2)
			f = 1
			break
		K -= 1
		heappush(a, e1)
		heappush(mx, -e2)
	if not f:
		print(sum(a))


def cal(a, b, k):
	a = sorted(a)
	b = sorted(b)
	if k == 0:
		return sum(a)
	if a[0] < b[-1]:
		temp = a[0]
		a[0] = b[-1]
		b[-1] = temp
	return cal(a, b, k - 1)

def web():
	T = int(input())
	for t in range(1, T + 1):
		arr = [int(s) for s in input().split(' ')]
		k = arr[1]
		a = [int(s) for s in input().split(' ')]
		b = [int(s) for s in input().split(' ')]
		ans = cal(a, b, k)
		print(str(ans))

def file():
	x = open('p2_in.txt')
	T = int(x.readline())
	for t in range(1, T + 1):
		arr = [int(s) for s in x.readline().split(' ')]
		k = arr[1]
		a = [int(s) for s in x.readline().split(' ')]
		b = [int(s) for s in x.readline().split(' ')]
		ans = cal(a, b, k)
		print(str(ans))
web()


INF = 1 << 60
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		a.sort()
		b.sort()
		if a[0] >= b[-1]:
			break
		(a[0], b[-1]) = (b[-1], a[0])
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted([*map(int, input().split())], reverse=True)
	b = sorted([*map(int, input().split())])
	ans = 0
	for i in range(k):
		if a[-1] < b[n - 1 - i]:
			ans += b[n - 1 - i]
			a.pop()
		else:
			break
	print(ans + sum(a))


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

def gift():
	for _ in range(t):
		(n, k) = list(map(int, input().split()))
		lsta = list(map(int, input().split()))
		lstb = list(map(int, input().split()))
		lsta.sort()
		lstb.sort()
		res = sum(lsta)
		for i in range(k):
			if lsta[i] < lstb[n - i - 1]:
				res += lstb[n - i - 1] - lsta[i]
			else:
				break
		yield res
t = int(input())
ans = gift()
print(*ans, sep='\n')


ncases = int(input())
for i in range(ncases):
	(n, k) = map(int, input().split())
	A = sorted(list(map(int, input().split())))
	B = sorted(list(map(int, input().split())))
	while A[0] < B[-1] and k != 0:
		(A[0], B[-1]) = (B[-1], A[0])
		A.sort()
		B.sort()
		k -= 1
	ans = 0
	for x in A:
		ans += x
	print(ans)


for i in range(int(input())):
	(n, k) = [int(num) for num in input().split()]
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	if k == 0:
		print(sum(x))
		continue
	else:
		for i in range(k):
			if max(y) >= min(x):
				xi = x.index(min(x))
				yi = y.index(max(y))
				a = x[xi]
				x[xi] = y[yi]
				y[yi] = a
			else:
				continue
	print(sum(x))


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	b.sort()
	if k != 0:
		a.extend(b[-k:])
	a.sort()
	print(sum(a[k:]))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(a)
	for j in range(k):
		mi = min(a)
		ma = max(b)
		if mi < ma:
			a.remove(mi)
			b.remove(ma)
			s = s - mi + ma
	print(s)


t = int(input())
nm = [[] for i in range(t)]
for i in range(t):
	nk = input().split()
	ins = input().split(' ')
	ins2 = input().split(' ')
	nm[i].append(nk)
	nm[i].append(ins)
	nm[i].append(ins2)
for i in range(t):
	nk = nm[i][0]
	a1 = nm[i][1]
	a2 = nm[i][2]
	n = int(nk[0])
	k = int(nk[1])
	for j in range(n):
		a1[j] = int(a1[j])
		a2[j] = int(a2[j])
	a1 = sorted(a1)
	a2 = sorted(a2, reverse=True)
	for ii in range(k):
		if a2[ii] <= a1[ii]:
			break
		else:
			a1[ii] = a2[ii]
	print(sum(a1))


import sys
t = int(input())
for _ in range(t):
	tt = sys.stdin.readline().split()
	k = int(tt[1])
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split(' ')))
	b = list(map(int, sys.stdin.readline().split(' ')))
	for _ in range(k):
		a_min = min(a)
		b_max = max(b)
		if a_min >= b_max:
			break
		a_min_i = a.index(a_min)
		b_max_i = b.index(b_max)
		a[a_min_i] = b_max
		b[b_max_i] = a_min
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	count = 0
	while count < k:
		if min(a) >= max(b):
			break
		else:
			swap1 = min(a)
			swap2 = max(b)
			a[a.index(swap1)] = swap2
			b[b.index(swap2)] = swap1
			count += 1
	print(sum(a))


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

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

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	t = I()
	ans = []
	for _ in range(t):
		(n, k) = LI()
		la = LI()
		lb = LI()
		la.sort(reverse=True)
		lb.sort()
		_la = []
		for _ in range(k):
			a = la.pop()
			b = lb.pop()
			if a > b:
				la += [a]
				break
			else:
				_la.append(b)
		la += _la
		ans.append(sum(la))
	for x in ans:
		print(x)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	s = sum(a)
	for x in range(k):
		s = max(s, s - a[x] + b[x])
	print(s)


cases = int(input())
for x in range(cases):
	temp = input()
	moves = int(temp.split()[1])
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort(reverse=True)
	for x in range(moves):
		if arr2[0] > arr1[0]:
			arr1[0] = arr2[0]
			arr1.sort()
			arr2.pop(0)
	print(sum(arr1))


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	a = sorted(list(map(int, stdin.readline().split())))
	b = sorted(list(map(int, stdin.readline().split())))
	swaps = 0
	for i in range(n):
		if swaps >= k:
			break
		j = n - i - 1
		if a[i] >= b[j]:
			break
		(a[i], b[j]) = (b[j], a[i])
		swaps += 1
	stdout.write(str(sum(a)) + '\n')


def solve1():
	(n, k) = map(int, input().split())
	A = [int(i) for i in input().split()]
	B = [int(i) for i in input().split()]
	A.sort()
	B.sort(reverse=1)
	ans = 0
	for i in range(n):
		if i < k:
			A[i] = max(A[i], B[i])
		ans += A[i]
	print(ans)
for _ in range(int(input())):
	solve1()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lisa = list(map(int, input().split()))
	lisb = list(map(int, input().split()))
	lisa.sort()
	lisb.sort(reverse=True)
	s = 0
	for i in range(n):
		if lisb[i] > lisa[i] and k:
			s += lisb[i]
			k -= 1
		else:
			s += lisa[i]
	print(s)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		if min(a) < max(b):
			(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	j = 0
	for i in range(k):
		m = max(b)
		if a[j] < m:
			a[j] = m
			b.remove(m)
			j += 1
		else:
			break
	print(sum(a))


n = int(input())
for i in range(n):
	x = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	p = 0
	q = x[0] - 1
	sum = 0
	for j in range(x[0]):
		if a[j] < b[q] and x[1] > 0:
			sum += b[q]
			x[1] -= 1
			q -= 1
		else:
			sum += a[j]
	print(sum)


t = int(input())
for ii in range(t):
	(n, k) = map(int, input().split())
	a = list()
	b = list()
	s = input().split()
	for i in s:
		a.append(int(i))
	s1 = input().split()
	for i in s1:
		b.append(int(i))
	while k != 0:
		min_a = 0
		max_b = 0
		for i in range(n):
			if a[min_a] > a[i]:
				min_a = i
			if b[max_b] < b[i]:
				max_b = i
		if a[min_a] >= b[max_b]:
			break
		(a[min_a], b[max_b]) = (b[max_b], a[min_a])
		k -= 1
	ans = 0
	for i in range(n):
		ans += a[i]
	print(ans)


import sys
import math
import itertools
from copy import copy
from collections import deque, Counter
from decimal import Decimal

def s():
	return input()

def i():
	return int(input())

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

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

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

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

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 9)
mod = 10 ** 9 + 7
t = i()
for i in range(t):
	(n, k) = I()
	a = l()
	a.sort()
	b = l()
	b.sort(reverse=True)
	for j in range(k):
		if a[j] < b[j]:
			a[j] = b[j]
		else:
			break
	print(sum(a))


t = int(input())
for test in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	afinal = []
	i = 0
	count = k
	while i < n and count > 0:
		if b[i] > a[i]:
			afinal.append(b[i])
			count -= 1
			i += 1
		else:
			break
	afinal = afinal + a[i:]
	print(sum(afinal))


t = int(input())
for jhg in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(y) for y in input().split()]
	a.sort()
	b.sort()
	i = 0
	count = 0
	while i < n and count < k:
		if a[i] > b[n - i - 1]:
			break
		else:
			a[i] = b[n - i - 1]
		i += 1
		count += 1
	print(sum(a))


from collections import defaultdict, deque
import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(m):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()[:n]]
	b = [int(i) for i in input().split()[:n]]
	b.sort(reverse=True)
	s = a + b[:k]
	s.sort(reverse=True)
	print(sum(s[:n]))


t = int(input())
a = 0
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a1 = input().split()
	b1 = input().split()
	a = []
	b = []
	for i in a1:
		a.append(int(i))
	for i in b1:
		b.append(int(i))
	for i in range(k):
		if min(a) <= max(b):
			t1 = b.index(max(b))
			t2 = a.index(min(a))
			(b[t1], a[t2]) = (a[t2], b[t1])
	print(sum(a))


t = int(input())
for j in range(t):
	(n, k) = (int(i) for i in input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	b.sort(reverse=True)
	a.extend(b[:k])
	a.sort(reverse=True)
	print(sum(a[:n]))


import sys
TEST = 0
if TEST == 1:
	input_file = open('inputB.txt', 'r')
	input_from_file = input_file.readlines()

def read_int():
	if TEST:
		return int(input_from_file.pop(0))
	else:
		return int(sys.stdin.readline())

def read_ints():
	if TEST:
		return list(map(int, input_from_file.pop(0).rstrip().split()))
	else:
		return list(map(int, sys.stdin.readline().split()))
t = read_int()
for test in range(t):
	(n, k) = read_ints()
	a = read_ints()
	b = read_ints()
	if k == 0:
		print(sum(a))
	else:
		a_sort = sorted(a, reverse=True)
		b_sort = sorted(b)
		if k > n:
			b_last = b_sort
		else:
			b_last = b_sort[-k:]
		a_sort.extend(b_last)
		a_sort = sorted(a_sort, reverse=True)
		print(sum(a_sort[:n]))


ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
for _ in range(ii()):
	(n, k) = f()
	a = il()
	b = il()
	a.sort()
	b.sort(reverse=True)
	for i in range(0, k):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))


t = int(input())
for j1 in range(t):
	(n, k) = map(int, input().split(' '))
	maxi = sorted(list(map(int, input().split(' '))))
	mini = sorted(list(map(int, input().split(' '))), reverse=True)
	sum1 = 0
	count = 0
	for (i, j) in zip(maxi, mini):
		if count < k and i < j:
			sum1 += j
			count += 1
		else:
			sum1 += i
	print(sum1)


from sys import stdin, stdout
from heapq import heapify, heappop, heappush
test = int(stdin.readline())
for _ in range(test):
	(n, k) = map(int, stdin.readline().split())
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	if k == n:
		temp = a + b
		ans = sum(list(reversed(sorted(a + b)))[:n])
		print(ans)
		continue
	heapify(a)
	b = [-1 * x for x in b]
	heapify(b)
	for i in range(k):
		x = heappop(b)
		y = heappop(a)
		if -1 * x < y:
			heappush(a, y)
			heappush(b, x)
			break
		heappush(a, -x)
		heappush(b, y)
	print(sum(a))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = map(int, input().split())
	b = map(int, input().split())
	sort = sorted(a)
	sb = sorted(b, reverse=True)
	if k == 0:
		print(sum(sort))
	else:
		for x in range(k):
			if sort[x] < sb[x]:
				sort[x] = sb[x]
		print(sum(sort))


t = int(input())
for jh in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	if k == 0:
		print(sum(a))
		continue
	if b[-1] <= a[0]:
		print(sum(a))
		continue
	if b[0] > a[-1]:
		print(sum(a[k:]) + sum(b[n - k:]))
		continue
	x = 0
	for i in range(n):
		if a[i] > b[n - i - 1]:
			break
		x += 1
	if x <= k:
		print(sum(a[x:]) + sum(b[n - x:]))
		continue
	else:
		print(sum(a[k:]) + sum(b[n - k:]))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = [int(x) for x in input().split()]
	l.sort()
	l1 = [int(x) for x in input().split()]
	l1.sort(reverse=True)
	for i in range(k):
		if l[i] < l1[i]:
			(l[i], l1[i]) = (l1[i], l[i])
		else:
			continue
	print(sum(l))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	list1 = sorted(list1)
	list2 = sorted(list2, reverse=True)
	tot = 0
	i = 0
	while k > 0 and i < n:
		if list2[i] > list1[i]:
			tot += list2[i]
			k -= 1
		else:
			break
		i += 1
	while i < n:
		tot += list1[i]
		i += 1
	print(tot)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if min(a) >= max(b):
			break
		else:
			a.pop(0)
			a.append(b.pop())
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	x = 0
	while x < k:
		if a[0] < b[-1]:
			p = a.pop(0)
			q = b.pop(-1)
			a.append(q)
			b.insert(0, p)
			x += 1
		else:
			break
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = sorted(a)
	b = sorted(b, reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))


import sys
input = sys.stdin.readline
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if min(a) >= max(b):
		print(sum(a))
	else:
		for i in range(k):
			if min(a) >= max(b):
				break
			else:
				b.append(min(a))
				a.remove(min(a))
				a.append(max(b))
				b.remove(max(b))
		print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	check = ''
	while i < k:
		a.sort()
		b.sort()
		value = sum(a)
		(a[0], b[-1]) = (b[-1], a[0])
		if value > sum(a):
			print(value)
			check += '+'
			break
		else:
			i += 1
			continue
	if check != '+':
		print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for ki in range(k):
		if max(b) <= min(a):
			break
		(i, br) = min(list(enumerate(a)), key=lambda p: p[1])
		(j, brr) = max(list(enumerate(b)), key=lambda p: p[1])
		tmp = a[i]
		a[i] = b[j]
		b[j] = tmp
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	candidates_a = a[:k]
	candidates_b = b[:k]
	suma = sum(a)
	idx = 0
	while idx < k:
		if candidates_a[idx] < candidates_b[idx]:
			suma -= candidates_a[idx]
			suma += candidates_b[idx]
			idx += 1
		else:
			break
	print(suma)


n = int(input())
for i in range(n):
	k = 0
	l = list(map(int, input().split()))
	m = list(map(int, input().split()))
	n = list(map(int, input().split()))
	m.sort()
	n.sort(reverse=True)
	for j in range(l[1]):
		if n[j] > m[j]:
			k += n[j]
		else:
			k += m[j]
	for j in range(l[1], l[0]):
		k += m[j]
	print(k)


test = int(input())
for i in range(test):
	(n, k) = map(int, input().split())
	a = input().split()
	a = [int(i) for i in a]
	b = input().split()
	b = [int(i) for i in b]
	a.sort()
	b.sort(reverse=True)
	ind = 0
	for i in range(k):
		ind = i
		if b[ind] > a[ind]:
			a[ind] = b[ind]
		if i == len(a):
			break
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = [int(j) for j in input().split()]
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[::-1][i]:
			a[i] = b[::-1][i]
	print(sum(a))


try:
	for _ in range(int(input())):
		(x, y) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		for k in range(int(y)):
			if max(b) > min(a):
				a.remove(min(a))
				a.append(max(b))
				b.remove(max(b))
			else:
				break
		print(sum(a))
except EOFError as e:
	pass


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k:
		mini = min(a)
		maxi = max(b)
		if mini >= maxi:
			break
		else:
			mini_index = a.index(mini)
			maxi_index = b.index(maxi)
			(a[mini_index], b[maxi_index]) = (b[maxi_index], a[mini_index])
		k -= 1
	print(sum(a))
	t -= 1


from pprint import pprint
import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	dat1 = list(map(int, input().split()))
	dat2 = list(map(int, input().split()))
	dat1.sort()
	dat2.sort(reverse=True)
	for i in range(k):
		if dat2[i] > dat1[i]:
			dat1[i] = dat2[i]
	print(sum(dat1))


from math import *
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
		else:
			break
	s = 0
	for i in range(n):
		s = s + a[i]
	print(s)


k = int(input())
count = []
for i in range(0, k):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	x = list(map(int, input().split()))
	l.sort()
	x.sort(reverse=True)
	for i in range(0, m):
		if l[i] < x[i]:
			(l[i], x[i]) = (x[i], l[i])
	count.append(str(sum(l)))
print(' '.join(count))


t = int(input())
while t > 0:
	t -= 1
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	sum = 0
	f = 0
	if k == 0:
		for i in range(n):
			sum += a[i]
		print(sum)
	else:
		for i in range(k):
			g = max(b)
			if a[i] < g:
				a[i] = g
				b.remove(g)
		for i in range(n):
			sum += a[i]
		print(sum)


import sys
import math
from math import factorial, inf, gcd, sqrt
from heapq import *
from functools import *
from itertools import *
from collections import *
from typing import *
from bisect import *
import random
sys.setrecursionlimit(10 ** 5)

def rarray():
	return [int(i) for i in input().split()]
t = 1
t = int(input())
for ii in range(t):
	(n, k) = rarray()
	a = rarray()
	b = rarray()
	a.sort()
	b.sort(reverse=True)
	ans = s = sum(a)
	for i in range(k):
		if b[i] <= a[i]:
			break
		ans += b[i] - a[i]
	print(ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	for x in range(k):
		if b[j] > a[i]:
			a[i] = b[j]
			j -= 1
			i += 1
	print(sum(a))


for e in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr.sort()
	brr.sort(reverse=True)
	for i in range(k):
		if brr[i] > arr[i]:
			arr[i] = brr[i]
	print(sum(arr))


import sys
import math

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

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

def printwsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')

def printchk(*args):
	return print(*args, end='tst, ')
MODPRIME = int(1000000000.0 + 7)
BABYMOD = 998244353
for _testcases_ in range(int(input())):
	(n, k) = get_ints()
	a = get_array()
	b = get_array()
	ans = 0
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		ans += max(a[i], b[i])
	for i in range(k, n):
		ans += a[i]
	print(ans)


from sys import *
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	a = a + b[:k]
	a.sort(reverse=True)
	ans = sum(a[:n])
	stdout.write(str(ans) + '\n')


test = int(input())
while test > 0:
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < k:
		if not b[i] < a[i]:
			a[i] = b[i]
		i += 1
	print(sum(a))
	test = test - 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	sum1 = sum(l1)
	for j in range(k):
		if l1[j] < l2[len(l2) - 1 - j]:
			sum1 = sum1 + l2[len(l2) - 1 - j] - l1[j]
	print(sum1)


import sys
inp = [int(x) for x in sys.stdin.buffer.read().split()]
ii = 0
qqq = inp[ii]
ii += 1
for _ in range(qqq):
	(n, k) = inp[ii:ii + 2]
	ii += 2
	a = sorted(inp[ii:ii + n])
	ii += n
	b = sorted(inp[ii:ii + n])
	ii += n
	b.reverse()
	res = sum(a)
	for i in range(k):
		if a[i] >= b[i]:
			break
		else:
			res += b[i] - a[i]
	print(res)


import sys
agGK = int(input())
for _ in range(agGK):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split(' ', n - 1)]
	b = [int(i) for i in input().split(' ', n - 1)]
	a.sort()
	b.sort()
	if n - k - 1 == 0:
		g = 0
	else:
		g = n - k - 1
	for i in range(n - 1, g, -1):
		if a[n - i - 1] < b[i]:
			a[n - i - 1] = b[i]
		else:
			break
	print(sum(a))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	m = 0
	if sum(a) >= sum(b) and min(a) > max(b) or k == 0:
		print(sum(a))
	else:
		for i in range(k):
			l = a[i + 1:] + b[n - i - 1:]
			if sum(l) > m:
				m = sum(l)
		print(m)
	t = t - 1


ans = ''
for _ in range(int(input())):
	nk = list(map(int, input().split()))
	n = nk[0]
	k = nk[1]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	pos = 0
	for i in range(0, k):
		if b[i] > a[i]:
			a[i] = b[i]
	ans += str(sum(a)) + '\n'
print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(n):
		if len(b) == 0 or k == 0:
			break
		maxx = max(b)
		if maxx > a[i]:
			c = a[i]
			a[i] = maxx
			b.remove(maxx)
			k -= 1
	print(sum(a))


import sys
readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	(n, k) = nm()
	a = nl()
	b = nl()
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] >= b[i]:
			break
		a[i] = b[i]
	print(sum(a))
	return
T = ni()
for _ in range(T):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	c1 = 0
	for j in range(n):
		if c1 == k:
			break
		if a[j] < b[j]:
			a[j] = b[j]
			c1 += 1
	print(sum(a))


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		a.sort()
		b = list(map(int, input().split()))
		b.sort(reverse=True)
		s = 0
		for i in range(n):
			if i < k and b[i] > a[i]:
				s += b[i]
			else:
				s += a[i]
		print(s)
main()


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	temp = sum(a[k:])
	for i in range(min(k, n)):
		if a[i] >= b[i]:
			temp += a[i]
		else:
			temp += b[i]
	print(temp)
	return
t = int(input())
while t:
	main()
	t -= 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	sum = 0
	for i in range(0, len(a)):
		sum = sum + a[i]
	j = 1
	for i in range(0, len(a)):
		if a[i] > b[len(a) - j] or k <= 0:
			break
		elif a[i] <= b[len(a) - j]:
			sum = sum - a[i] + b[len(a) - j]
			j = j + 1
			k = k - 1
	print(sum)


test_cases = int(input())
for _ in range(test_cases):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	answer = sum(a)
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			answer = answer + b[i] - a[i]
	print(answer)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = sorted(list(map(int, input().split())))
	ar1 = sorted(list(map(int, input().split())), reverse=True)
	i = 0
	j = 0
	while j < k:
		if ar[i] < ar1[i]:
			(ar[i], ar1[i]) = (ar1[i], ar[i])
		i += 1
		j += 1
	print(sum(ar))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arrA = list(map(int, input().split()))
	arrB = list(map(int, input().split()))
	arrA = sorted(arrA)
	arrB = sorted(arrB, reverse=True)
	for i in range(n):
		if k > 0 and arrB[i] > arrA[i]:
			arrA[i] = arrB[i]
			k -= 1
	s = sum(arrA)
	print(s)


def swap(a, b, i, j):
	temp = a[i]
	a[i] = b[j]
	b[j] = temp

def solve(n, k, a, b):
	for i in range(k):
		if b[i] > a[i]:
			(a[i], b[i]) = (b[i], a[i])
		else:
			break
	return sum(a)
t = int(input())
for j in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	print(solve(n, k, a, b))


import sys
input = sys.stdin.readline
import heapq
t = int(input())
for tests in range(t):
	(n, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = sorted(map(int, input().split()), reverse=True)
	heapq.heapify(A)
	for i in range(k):
		x = heapq.heappop(A)
		if B[i] > x:
			x = B[i]
		heapq.heappush(A, x)
	print(sum(A))


def fun(n, k, a, b):
	flag = False
	count = 0
	while flag != True and count < k:
		minn = min(a)
		maxx = max(b)
		if minn < maxx:
			ekbarswap = False
			for i in range(n):
				if ekbarswap == False and a[i] == minn:
					for j in range(n):
						if b[j] == maxx:
							a[i] = maxx
							b[j] = minn
							count += 1
							ekbarswap = True
							break
		else:
			flag = True
	s = 0
	for ele in a:
		s += ele
	print(s)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = fun(n, k, a, b)


def swap(a, b, k, n):
	index = 0
	a.sort()
	b.sort(reverse=True)
	for i in range(len(a)):
		if a[i] < b[i] and index < k:
			(a[i], b[i]) = (b[i], a[i])
			index = index + 1
	return sum(a)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(swap(a, b, k, n))


def maxsum(n, k, a, b):
	miniIndex = None
	maxiIndex = None
	p = 0
	while p < k:
		mini = min(a)
		maxi = max(b)
		if mini >= maxi:
			return a
		else:
			i = 0
			j = 0
			while i < len(a):
				if a[i] == mini:
					miniIndex = i
				i += 1
			while j < len(b):
				if b[j] == maxi:
					maxiIndex = j
				j += 1
			(a[miniIndex], b[maxiIndex]) = (b[maxiIndex], a[miniIndex])
			p += 1
	return a
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	arr = maxsum(n, k, a, b)
	print(sum(arr))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if min(a) > max(b):
		print(sum(a))
		continue
	for i in range(k):
		inda = a.index(min(a))
		indb = b.index(max(b))
		(a[inda], b[indb]) = (b[indb], a[inda])
		if min(a) >= max(b):
			break
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	index = 0
	while k > 0 and index != n:
		if a[index] >= b[n - 1]:
			break
		else:
			x = a[index]
			a[index] = b[n - 1]
			b[n - 1] = x
			b.sort()
			k = k - 1
			index += 1
	ans = sum(a)
	print(ans)


def solve_task(a, b, k):
	a = list(a)
	a.sort()
	b = list(b)
	b.sort()
	n = len(a)
	step = 0
	while step < k:
		if a[0] < b[n - 1]:
			(a[0], b[n - 1]) = (b[n - 1], a[0])
			step += 1
			a.sort()
			b.sort()
		else:
			break
	return sum(a)

def main():
	n_tests = int(input())
	solutions = []
	for t in range(n_tests):
		aa = input().split()
		a = input()
		b = input()
		a = [int(i) for i in a.split()]
		b = [int(i) for i in b.split()]
		solutions.append(solve_task(a, b, int(aa[1])))
	for s in solutions:
		print(s)
main()


tests = int(input())
for _ in range(tests):
	(each_len, exchanges) = map(int, input().split())
	list_a = list(map(int, input().split()))
	list_a.sort()
	list_b = list(map(int, input().split()))
	list_b.sort(reverse=True)
	for i in range(exchanges):
		if list_a[i] < list_b[i]:
			(list_a[i], list_b[i]) = (list_b[i], list_a[i])
		elif list_a[i] >= list_b[i]:
			break
	print(sum(list_a))


import math
import atexit
import io
import sys
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def array_to_string(a):
	s = ''
	for i in a:
		s += str(i) + ' '
	return s[0:len(s) - 1]

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

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

def lcm(a, b):
	return a * b / gcd(a, b)
t = int(input())
while t > 0:
	t = t - 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	c = 0
	for i in range(n):
		for j in range(n):
			if c == k:
				break
			if a[i] < b[j]:
				(a[i], b[j]) = (b[j], a[i])
				c += 1
		if c == k:
			break
	print(sum(a))


def solve(k):
	a.sort()
	b.sort(reverse=True)
	(idx_a, idx_b) = (0, 0)
	for i in range(N):
		if not k:
			break
		while idx_b < N:
			if a[i] < b[idx_b]:
				(a[i], b[idx_b]) = (b[idx_b], a[i])
				k -= 1
				break
			idx_b += 1
	return sum(a)
for _ in range(int(input())):
	(N, K) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(K))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	print(sum(sorted(b[:k] + a, reverse=True)[:len(a)]))


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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 value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]
for _ in range(int(input())):
	(n, k) = value()
	a = sorted(array())
	b = sorted(array(), reverse=True)
	i = 0
	j = 0
	while i < n and j < n and (k > 0):
		if b[j] > a[i]:
			j += 1
			a[i] = b[i]
			k -= 1
		i += 1
	print(sum(a))


qtd = int(input())
for _ in range(qtd):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	for y in range(k):
		if a[y] < b[len(a) - 1 - y]:
			a[y] = b[len(b) - 1 - y]
	print(sum(a))


max_int = 1000000001
min_int = -1000000001
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sum_a = sum(a)
	for _k in range(k):
		min_a = min(a)
		a.remove(min_a)
		max_b = max(b)
		b.remove(max_b)
		if max_b <= min_a:
			break
		sum_a = sum_a + max_b - min_a
		if not b:
			break
	print(sum_a)


for it in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ans = 0
	for i in range(n):
		if i < k and b[i] > a[i]:
			ans += b[i]
		else:
			ans += a[i]
	print(ans)


Read = lambda : map(int, input().split())
for t in range(int(input())):
	(n, k) = Read()
	a = sorted(Read())
	b = sorted(Read(), reverse=True)
	s = sorted(a + b[:k], reverse=True)
	print(sum(s[:n]))


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	count = 0
	i = 0
	ans = 0
	while i < n and a[i] < b[i] and (count < k):
		ans += b[i]
		i += 1
		count += 1
	while i < n:
		ans += a[i]
		i += 1
	print(ans)
t = int(input())
for _ in range(t):
	solve()


a = []
b = []
t = int(input())
for i in range(t):
	y = input().split()
	y[0] = int(y[0])
	y[1] = int(y[1])
	a1 = input().split()
	b1 = input().split()
	a1 = list(map(int, a1))
	b1 = list(map(int, b1))
	a1.sort()
	b1.sort(reverse=True)
	flag = 0
	for i in range(0, len(a1)):
		if flag == y[1]:
			break
		elif int(b1[i]) > int(a1[i]):
			a1[i] = b1[i]
			flag += 1
	print(sum(a1))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	(a, b, c, l, s) = (0, 0, 0, [], [])
	l1 = sorted(list(map(int, input().split())))
	l2 = sorted(list(map(int, input().split())), reverse=True)
	for i in range(k):
		if l2[i] > l1[i]:
			(l1[i], l2[i]) = (l2[i], l1[i])
	print(sum(l1))


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	x = [int(j) for j in input().split()]
	y = [int(p) for p in input().split()]
	x.sort()
	y.sort(reverse=True)
	for l in range(0, k):
		if x[l] < y[l]:
			x[l] = y[l]
	print(sum(x))


def somatudo(lista):
	soma = 0
	for e in lista:
		soma += e
	return soma

def troca_maior(a, b):
	menora = min(a)
	maiorb = max(b)
	if maiorb > menora:
		for i in range(len(a)):
			if a[i] == menora:
				a[i] = maiorb
				break
		for i in range(len(b)):
			if b[i] == maiorb:
				b[i] = menora
				break
t = int(input())
for e in range(t):
	entrada = [int(x) for x in input().split()]
	n = entrada[0]
	k = entrada[1]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	while k:
		troca_maior(a, b)
		k -= 1
	print(somatudo(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	sumi = 0
	for i in range(n):
		if b[i] > a[i] and i < k:
			sumi += b[i]
		else:
			sumi += a[i]
	print(sumi)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	c = n - 1
	g = n - 1
	ans = 0
	f = 0
	for i in range(n):
		if b[c] > a[g] and f < k:
			ans += b[c]
			c -= 1
			f += 1
		else:
			ans += a[g]
			g -= 1
	print(ans)


t = int(input())
z = 0
while z < t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(a)
	d = list(b)
	for i in range(k):
		e = min(a)
		f = max(b)
		if e < f:
			a.remove(e)
			a.append(f)
			b.remove(f)
	print(sum(a))
	z += 1


t = int(input())
lst1 = list()
lst2 = list()
lst3 = list()
for i in range(t):
	lst1.append(input().split())
	lst2.append(input().split())
	lst3.append(input().split())
for i in range(t):
	for j in range(2):
		lst1[i][j] = int(lst1[i][j])
for i in range(t):
	for j in range(int(lst1[i][0])):
		lst2[i][j] = int(lst2[i][j])
		lst3[i][j] = int(lst3[i][j])
for i in range(t):
	lst2[i].sort()
	lst3[i].sort(reverse=True)
for i in range(t):
	for j in range(lst1[i][1]):
		if lst3[i][j] > lst2[i][j]:
			tem = lst2[i][j]
			lst2[i][j] = lst3[i][j]
			lst3[i][j] = tem
for i in range(t):
	print(sum(lst2[i]))


from sys import stdin, stdout
q = int(input())
for i in range(q):
	(n, k) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	a.sort()
	b.sort()
	cnt = 0
	a = a[::-1]
	b = b[::-1]
	j = 0
	cnt1 = 0
	sum1 = 0
	l = 0
	while cnt1 < n:
		cnt1 += 1
		if a[l] < b[j] and cnt < k:
			sum1 = sum1 + b[j]
			j += 1
			cnt = cnt + 1
		else:
			sum1 = sum1 + a[l]
			l += 1
	print(sum1)


def max_sum(a, b, a_pos, b_pos, k, n):
	if n == 0:
		return 0
	elif a[a_pos - 1] < b[b_pos - 1] and k:
		return b[b_pos - 1] + max_sum(a, b, a_pos, b_pos - 1, k - 1, n - 1)
	else:
		return a[a_pos - 1] + max_sum(a, b, a_pos - 1, b_pos, k, n - 1)
t = int(input())
result = list()
for test_case in range(t):
	n = input()
	n = n.split()
	k = int(n[1])
	n = int(n[0])
	a = input()
	a = a.split()
	a = list(map(int, a))
	b = input()
	b = b.split()
	b = list(map(int, b))
	a.sort()
	b.sort()
	result.append(max_sum(a, b, n, n, k, n))
for i in result:
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for x in range(k):
		if a[a.index(min(a))] >= b[b.index(max(b))]:
			break
		(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
	print(sum(a))


import collections

def solve(n, k, a, b):
	aAsc = sorted(a)
	bDes = sorted(b, reverse=True)
	ans = 0
	bDex = 0
	for i in range(n):
		if k > 0 and bDex < n and (aAsc[i] < bDes[bDex]):
			ans += bDes[bDex]
			bDex += 1
			k -= 1
		else:
			ans += aAsc[i]
	return ans
t = int(input().strip())
for i in range(t):
	[n, k] = list(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	print(solve(n, k, a, b))


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	i = 0
	j = len(b) - 1
	while k != 0:
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
		i += 1
		j -= 1
		k -= 1
	print(sum(a))


n = int(input())
s = []
for i in range(n):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for t in range(k):
		minv = a[0]
		for r in a:
			if r < minv:
				minv = r
		maxv = b[0]
		for e in b:
			if e > maxv:
				maxv = e
		if minv < maxv:
			a.remove(minv)
			a.append(maxv)
			b.remove(maxv)
	sumn = 0
	for q in a:
		sumn += q
	s += [sumn]
for w in s:
	print(w)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		a[i] = max(a[i], b[i])
	print(sum(a))
	t -= 1


from sys import stdin
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in stdin.readline().split()]
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	for __ in range(k):
		amin = min(a)
		bmax = max(b)
		if bmax >= amin:
			a[a.index(amin)] = b.pop(b.index(bmax))
		else:
			break
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in range(k):
		aI = a.index(min(a))
		bI = b.index(max(b))
		if a[aI] < b[bI]:
			(a[aI], b[bI]) = (b[bI], a[aI])
	sum = 0
	for i in a:
		sum += i
	print(sum)


author = 'DarshanMohan'
import sys

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

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

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

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

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST():
	return list(MAP())

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')

def SWAP(a, b):
	(a, b) = (b, a)
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def add(a, b, c):
	res = a + b
	if res >= c:
		return res - c
	else:
		return res

def mod(a, b, c):
	res = a * b
	if res >= c:
		return res % c
	else:
		return res

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

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

def expo(a, b):
	(x, y) = (1, a)
	while b > 0:
		if b & 1:
			x = x * y
		y = y * y
		b >>= 1
	return x

def power(a, b, m):
	(x, y) = (1, 1)
	while b > 0:
		if b & 1:
			x = mod(x, y, m)
		y = mod(y, y, m)
		b >>= 1
	return x

def inv(a, m):
	return power(a, m - 2, m)

def mod_inverse(a, n):
	N = n
	xx = 0
	yy = 1
	y = 0
	x = 1
	while n > 0:
		q = a // n
		t = n
		n = a % n
		a = t
		t = xx
		xx = x - q * xx
		x = t
		t = yy
		yy = y - q * yy
		y = t
	x %= N
	x += N
	x %= N
	return x
for _ in range(int(input())):
	(n, k) = MAP()
	a = LIST()
	b = LIST()
	a.sort()
	temp = 0
	b.sort(reverse=True)
	if k > 0:
		for i in range(n):
			if a[i] < b[i]:
				a[i] = b[i]
				temp += 1
			if temp == k:
				break
	print(sum(a))


t = int(input())
ans = []
for i in range(t):
	(n, m) = map(int, input().split())
	ls1 = list(map(int, input().split()))
	ls2 = list(map(int, input().split()))
	ls1.sort()
	ls2.sort(reverse=True)
	x = 0
	j = -1
	for j in range(0, m):
		x += max(ls1[j], ls2[j])
		temp = j
	for k in range(j + 1, len(ls1)):
		x += ls1[k]
	ans.append(x)
for i in range(t):
	print(ans[i])


x = int(input())
for i in range(x):
	(a, b) = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	for j in range(b):
		if min(c) < max(d):
			e = c.index(min(c))
			f = d.index(max(d))
			(c[e], d[f]) = (d[f], c[e])
		else:
			break
	print(sum(c))


t = int(input())

def solve(n, k, a, b):
	a = sorted(a)
	b = sorted(b)
	for i in range(k):
		(x, y) = (a[i], b[-(i + 1)])
		if x < y:
			a[i] = b[-(i + 1)]
		else:
			break
	print(sum(a))
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(n, k, a, b)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	ar1 = list(map(int, input().split()))
	ar2 = list(map(int, input().split()))
	ar1.sort(reverse=True)
	ar2.sort(reverse=True)
	i = 0
	j = 0
	ans = 0
	while k > 0 and i < n and (j < n) and (i + j < n):
		if ar1[i] > ar2[j]:
			ans += ar1[i]
			i += 1
		else:
			ans += ar2[j]
			j += 1
			k -= 1
	for h in range(i, n - j):
		ans += ar1[h]
	print(ans)


kl = int(input())
for l in range(kl):
	(n, k) = map(int, input().split())
	c = [0] * 2 * k
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	c = a[:k] + b[n - k:]
	c.sort()
	s = 0
	for i in range(k):
		s += c[k + i]
	for i in range(n - k):
		s += a[k + i]
	print(s)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	while i < k and min(a) < max(b):
		temp = max(b)
		b.remove(max(b))
		b.append(min(a))
		a.remove(min(a))
		a.append(temp)
		i = i + 1
	print(sum(a))


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = sorted(a)
	b = sorted(b)
	count = 0
	for j in range(0, len(a)):
		if a[j] <= b[len(b) - j - 1] and count < k:
			a[j] = b[len(b) - j - 1]
			count += 1
		elif a[j] > b[len(b) - j - 1]:
			break
	print(sum(a))
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	(ai, bi) = (0, 0)
	while k > 0:
		if a[ai] < b[bi]:
			(a[ai], b[bi]) = (b[bi], a[ai])
			ai += 1
			bi += 1
			k -= 1
		else:
			break
	print(sum(a))


t = int(input())
for i in range(0, t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = 0
	for i in range(0, k):
		if min(a) < max(b):
			s = s + max(b)
			x = min(a)
			y = max(b)
			a.remove(x)
			b.remove(y)
		else:
			break
	print(s + sum(a))


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	ans = 0
	i = 0
	j = n - k
	ans = sum(a[:n - k])
	new = []
	new += a[n - k:]
	new += b
	new.sort(reverse=True)
	print(ans + sum(new[:k]))


cases = int(input())
for i in range(cases):
	(le, moves) = [int(p) for p in input().split()]
	a = [int(p) for p in input().split()]
	b = [int(p) for p in input().split()]
	for j in range(moves):
		if max(b) >= min(a):
			gb = b.pop(b.index(max(b)))
			ab = a.pop(a.index(min(a)))
			a.append(gb)
			b.append(ab)
	print(sum(a))


d = input()
for j in range(int(d)):
	c = input().split(' ')
	d = input().split(' ')
	list1 = [int(i) for i in d]
	d = input().split(' ')
	list2 = [int(i) for i in d]
	list1.sort()
	list2.sort()
	for i in range(int(c[1])):
		if list1[i] < list2[len(list2) - 1 - i]:
			list1[i] = list2[len(list2) - 1 - i]
		else:
			break
	print(sum(list1))


def solve(n, k, a, b):
	a.sort()
	b.sort()
	b.reverse()
	i = 0
	if k == 0:
		print(sum(a))
		return
	for i in range(n):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
			k -= 1
		if k == 0:
			break
	print(sum(a))
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(n, k, a, b)


c = int(input())
for _ in range(c):
	string1 = input().split()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(n, k) = (int(string1[0]), int(string1[1]))
	a.sort()
	b.sort()
	max = 0
	for i in range(k + 1):
		new_sum = sum(a[i:]) + sum(b[n - i:])
		if new_sum > max:
			max = new_sum
	print(max)


for i in range(int(input())):
	(n, k) = map(int, input().split(' '))
	a = sorted(list(map(int, input().split(' '))))
	b = sorted(list(map(int, input().split(' '))))
	(j, count) = (0, 0)
	while j <= n - 1 and a[j] < b[n - j - 1] and (count < k):
		(b[n - j - 1], a[j]) = (a[j], b[n - j - 1])
		count += 1
		j += 1
	print(sum(a))


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
Read = lambda : list(map(int, input().split()))
Num = lambda : int(input())
exec("try:sys.stdin=open('in.txt','r');sys.stdout=open('out.txt','w')\nexcept:pass")

def solve():
	(n, k) = Read()
	a = Read()
	b = Read()
	a.sort(reverse=1)
	b.sort()
	ans = 0
	for i in range(n - 1, -1, -1):
		if k:
			ans += max(a[i], b[i])
			k -= 1
		else:
			ans += a[i]
	print(ans)
for _ in range(Num()):
	solve()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	temp = k
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()), reverse=True)
	i = 0
	ans = 0
	while k and i < n:
		ans += max(a[i], b[i])
		k -= 1
		i += 1
	ans += sum(a[temp:])
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a_arr = sorted(map(int, input().split()))
	b_arr = sorted(map(int, input().split()), key=lambda v: -v)
	for i in range(k):
		if a_arr[i] >= b_arr[i]:
			break
		a_arr[i] = b_arr[i]
	print(sum(a_arr))


t = int(input())
for iii in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	r = []
	i = 0
	for i in range(k):
		r.append(a[i])
		r.append(b[n - k + i])
	r.sort()
	for j in range(k):
		a[j] = r[k + j]
	print(sum(a))


for i in range(int(input())):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	l = [int(a) for a in input().split()]
	j = [int(b) for b in input().split()]
	l.sort()
	j.sort(reverse=True)
	a = 0
	for h in range(n):
		if j[h] > l[h] and k > 0:
			a += j[h]
			k -= 1
		else:
			a += l[h]
	print(a)


import collections

def lis():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = lis()
	a.sort()
	b = lis()
	b.sort(reverse=True)
	d = []
	d = collections.deque((x for x in b))
	t = 0
	i = 0
	while i <= n - 1 and t < k:
		if a[i] < d[0]:
			a[i] = d[0]
			t += 1
			d.popleft()
		i += 1
	print(sum(a))


from sys import stdin
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(map(int, stdin.readline().split()))
	b = sorted(map(int, stdin.readline().split()), reverse=True)
	t = k
	for i in range(k):
		if a[i] >= b[i]:
			t = i
			break
	print(sum(b[:t]) + sum(a[t:]))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	k1 = 0
	fl = False
	while k != 0:
		if min(a) >= max(b):
			for j in a:
				k1 += j
			print(k1)
			fl = True
			break
		k -= 1
		for j in range(len(a)):
			if a[j] == min(a):
				x = a[j]
				y = max(b)
				for q in range(len(b)):
					if b[q] == max(b):
						b[q] = x
						a[j] = y
						break
				break
	if fl:
		continue
	for j in a:
		k1 += j
	print(k1)


import sys
from math import log, sqrt, factorial

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

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())
tt = ii()
while tt:
	tt -= 1
	(n, k) = mi()
	(a, b) = ([], [])
	(a, b) = (li(), li())
	a.sort()
	b.sort(reverse=1)
	(s, i) = (0, 0)
	while i < n and i < k:
		if b[i] > a[i]:
			s += b[i]
		else:
			s += a[i]
		i += 1
	if k < n:
		while k < n:
			s += a[k]
			k += 1
	print(s)


from sys import stdin

def solve(n, k, a, b):
	a.sort()
	b.sort(reverse=True)
	sm = 0
	for i in range(n):
		if i < k:
			sm += max(a[i], b[i])
		else:
			sm += a[i]
	print(sm)
	return

def main():
	inp = stdin.readline
	for _ in range(int(inp())):
		(n, k) = map(int, inp().split())
		a = list(map(int, inp().split()))
		b = list(map(int, inp().split()))
		solve(n, k, a, b)
main()


t = int(input())
for i in range(t):
	NK = list(map(int, input().split()))
	n = NK[0]
	k = NK[1]
	listA = list(map(int, input().split()))
	listB = list(map(int, input().split()))
	listA.sort()
	listB.sort()
	sum = 0
	i = 0
	j = n - 1
	while k > 0:
		if listB[j] > listA[i]:
			(listB[j], listA[i]) = (listA[i], listB[j])
			k -= 1
			j -= 1
			i += 1
		else:
			break
	for m in range(n):
		sum += listA[m]
	print(sum)


from sys import stdin

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

def sinput():
	return input()

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

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	(n, k) = minput()
	a = linput()
	b = linput()
	a.sort()
	b.sort(reverse=True)
	i = 0
	j = 0
	while i < n and j < n and (k > 0):
		if a[i] < b[j]:
			a[i] = b[j]
			i += 1
			k -= 1
		j += 1
	print(sum(a))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	ans = 0
	count = 0
	(n, k) = map(int, sys.stdin.readline().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] > b[i]:
			ans += a[i]
		else:
			ans += b[i]
	if k == n:
		pass
	else:
		ans += sum(a[k:])
	print(ans)


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	b = sorted(list(map(int, input().split())), reverse=True)
	c = sorted(a + b[:k], reverse=True)
	print(sum(c[:n]))


def task(n, k, a, b):
	a.sort()
	b.sort(reverse=True)
	for i in range(0, k):
		if a[i] < b[i]:
			tmp = a[i]
			a[i] = b[i]
			b[i] = tmp
		else:
			break
	print(sum(a))
t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	task(n, k, a, b)


def getN():
	return int(input())

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

def getList():
	return list(map(int, input().split()))
from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left
import sys
INF = 10 ** 17
MOD = 998244353

def solve():
	(n, k) = getList()
	anums = getList()
	bnums = getList()
	bnums.sort(key=lambda x: -x)
	ans = anums + bnums[:k]
	print(sum(list(sorted(ans, key=lambda x: -x))[:n]))

def main():
	n = getN()
	for _ in range(n):
		solve()
main()


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
		else:
			break
	print(sum(a))


lst1 = []
lst2 = []
t = int(input())
for i in range(t):
	sum = 0
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	lst1 = list(map(int, input().strip().split()))[:n]
	lst2 = list(map(int, input().strip().split()))[:n]
	lst1.sort()
	lst2.sort()
	for j in range(n):
		if lst1[j] < lst2[n - j - 1] and k > 0:
			t = lst1[j]
			lst1[j] = lst2[n - j - 1]
			lst2[n - j - 1] = t
			k = k - 1
			if k == 0:
				break
	for j in lst1:
		sum += j
	print(sum)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for p in range(k):
		index_min = a.index(min(a))
		index_max = b.index(max(b))
		if a[index_min] < b[index_max]:
			a[index_min] = b[index_max]
			b[index_max] = 0
	print(sum(a))


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def prr(a, sep=' ', end='\n'):
	print(sep.join(map(str, a)), end=end)

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
for _ in range(ii()):
	(n, m) = mi()
	a = sorted(li())
	b = sorted(li(), reverse=True)
	for i in range(m):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	c = 0
	s = 0
	for i in range(n):
		if a[i] < b[n - i - 1] and c < k:
			c += 1
			s += b[n - i - 1]
		else:
			s += a[i]
	print(s)


t = int(input())
answers = [0] * t
for i in range(t):
	(a, b) = input().split()
	numElements = int(a)
	numMoves = int(b)
	a = input().split()
	b = input().split()
	for j in range(numElements):
		(a[j], b[j]) = (int(a[j]), int(b[j]))
	while numMoves > 0:
		numMoves -= 1
		if min(a) < max(b):
			a.append(max(b))
			b.append(min(a))
			a.remove(min(a))
			b.remove(max(b))
		else:
			break
	for j in range(numElements):
		answers[i] += a[j]
for i in range(t):
	print(answers[i])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	for _ in range(k):
		if a[0] < b[-1]:
			(a[0], b[-1]) = (b[-1], a[0])
			a.sort()
			b.sort()
		else:
			break
	print(sum(a))


t = int(input())
for k in range(t):
	(n, k) = list(map(int, input().split()))
	arra = list(map(int, input().split()))
	arrb = list(map(int, input().split()))
	arra.sort()
	arrb.sort()
	arrb = arrb[::-1]
	sm = sum(arra)
	j = 0
	i = 0
	while i < n and j < n and (k > 0):
		if arrb[j] > arra[i]:
			sm += arrb[j] - arra[i]
			i += 1
			j += 1
			k -= 1
		else:
			break
	print(sm)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	b1 = q = 0
	for h in range(k):
		if b[-h - 1] > a[h]:
			b1 += b[-h - 1]
			q += 1
	for r in range(len(a) - q):
		b1 += a[-r - 1]
	print(b1)


mod = int(1000000000.0) + 7

def ip():
	return int(input())

def Ip():
	return map(int, input().split())
for _ in range(0, int(input())):
	(n, k) = Ip()
	a = list(Ip())
	b = list(Ip())
	a.sort()
	b.sort()
	s = sum(a)
	i = 0
	j = n - 1
	c = 0
	while c < k:
		c += 1
		if a[i] < b[j]:
			s = s + b[j] - a[i]
			i += 1
			j -= 1
	print(s)


from collections import defaultdict as dc
from collections import Counter
from heapq import *
import math
from bisect import bisect_left, bisect
import sys
from collections import deque as dq
from heapq import heapify, heappush, heappop
mod = 10 ** 9 + 7

def sinp():
	p = str(input())
	return p

def seive(n):
	p = [0] * (n + 1)
	for i in range(2, n):
		if p[i] == 0:
			for j in range(2 * i, n + 1, i):
				p[i] = 1
	return p

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

def line():
	p = list(map(int, input().split()))
	return p

def read_mat():
	n = inp()
	a = []
	for i in range(n):
		a.append(line())
	return a

def digit(n):
	s = str(n)
	p = 0
	for i in s:
		p += int(i) ** 2
	return p

def solve(n, k, a, b):
	a.sort()
	b.sort(reverse=True)
	s = 0
	for i in range(n):
		if k > 0:
			if a[i] < b[i]:
				s += b[i]
				k -= 1
			else:
				s += a[i]
		else:
			s += a[i]
	return s
for test in range(inp()):
	(n, k) = line()
	a = line()
	b = line()
	l = solve(n, k, a, b)
	print(l)


import sys

def process(n, k, a, b):
	sa = sorted(a)
	sb = sorted(b)
	result = 0
	for i in range(n):
		if i in range(k):
			if sa[i] < sb[n - i - 1]:
				result += sb[n - i - 1]
			else:
				result += sa[i]
		else:
			result += sa[i]
	print(result)
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())

def f(a, n):
	return True

def is_permutation(arr):
	for e in range(1, len(arr) + 1):
		if e not in arr:
			return False
	return True
t = inp()
for i in range(t):
	line1 = inlt()
	(n, k) = (line1[0], line1[1])
	a = inlt()
	b = inlt()
	process(n, k, a, b)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	p1 = 0
	p2 = 0
	s = 0
	while p1 < n and p2 < n and (s < k):
		if a[p1] < b[p2]:
			(a[p1], b[p2]) = (b[p2], a[p1])
			p1 += 1
			p2 += 1
			s += 1
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort(reverse=True)
	summ = sum(arr1)
	i = 0
	while k and i < n:
		if arr2[i] >= arr1[i]:
			summ = summ - arr1[i] + arr2[i]
		else:
			break
		i += 1
		k -= 1
	print(summ)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = sorted(map(int, input().split()))
	li1 = sorted(map(int, input().split()))
	aa = lis[:k] + li1[n - k:]
	aa.sort()
	ans = sum(lis[k:] + aa[k:])
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	if k == 0:
		print(sum(a))
	else:
		c = 0
		a.sort()
		b.sort(reverse=True)
		(i, j) = (0, 0)
		maxi = -1 * 10 ** 9
		while i < len(a) and j < len(b) and (c < k):
			if a[i] < b[j]:
				(a[i], b[j]) = (b[j], a[i])
				i += 1
				j += 1
				c += 1
			else:
				i += 1
				j += 1
		print(sum(a))


from heapq import heapify, heappop, heappush
for __ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		b[i] *= -1
	heapify(a)
	heapify(b)
	while k > 0 and a[0] < abs(b[0]):
		(x, y) = (heappop(a), heappop(b))
		heappush(a, -y)
		heappush(b, -x)
		k -= 1
	print(sum(a))


t = int(input())

def lst_sum(lst):
	sum_lst = 0
	for i in lst:
		sum_lst = sum_lst + i
	return sum_lst
for i in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	lst_a = input().split()
	lst_b = input().split()
	for i in range(n):
		lst_a[i] = int(lst_a[i])
		lst_b[i] = int(lst_b[i])
	while k != 0:
		if max(lst_b) > min(lst_a):
			el_b = lst_b.index(max(lst_b))
			el_a = lst_a.index(min(lst_a))
			temp = max(lst_b)
			lst_b[el_b] = min(lst_a)
			lst_a[el_a] = temp
		k = k - 1
	print(lst_sum(lst_a))


def solution(n, k, a, b):
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	while k > 0 and j >= 0 and (i < n):
		if a[i] >= b[j]:
			j -= 1
		else:
			(a[i], b[j]) = (b[j], a[i])
			i += 1
			j -= 1
			k -= 1
	return sum(a)
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	num = solution(n, k, a, b)
	print(num)


n = int(input())
while n > 0:
	(x, y) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	sum = 0
	A.sort()
	B.sort()
	i = k = 0
	while y > 0 and i < x:
		if A[i] < B[x - i - 1]:
			(A[i], B[x - i - 1]) = (B[x - i - 1], A[i])
		i += 1
		y -= 1
	for i in range(len(A)):
		sum += A[i]
	print(sum)
	n -= 1


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

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

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

def li():
	return [int(i) for i in input().split()]

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

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
for _ in range(ii()):
	(n, k) = mi()
	a = sorted(li())
	b = sorted(li(), reverse=True)
	i = 0
	while i < k:
		if a[i] < b[i]:
			a[i] = b[i]
		i += 1
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ans = 0
	i = 0
	while i < n:
		if a[i] >= b[i]:
			ans += a[i]
		elif k > 0:
			ans += b[i]
			k -= 1
		else:
			ans += a[i]
		i += 1
	print(ans)


t = int(input())

def somme(n, k, a, b):
	a.sort()
	b.sort(reverse=True)
	i = 0
	ismax = True
	while i < k and ismax == True:
		ismax = b[i] > a[i]
		if ismax:
			a[i] = b[i]
		i += 1
	return sum(a)
resultat = []
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	resultat.append(somme(n, k, a, b))
for _ in resultat:
	print(_)


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	l_a = [int(x) for x in input().split()]
	l_b = [int(x) for x in input().split()]
	l_a = sorted(l_a)
	l_b = sorted(l_b, reverse=True)
	if l_a[0] >= l_b[0]:
		print(sum(l_a))
	else:
		for j in range(n):
			if l_a[j] < l_b[j] and k > 0:
				l_a[j] = l_b[j]
				k -= 1
			elif k == 0:
				break
			elif l_a[j] >= l_b[j]:
				break
		print(sum(l_a))


import sys

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, sys.stdin.readline().split())
		a = list(map(int, sys.stdin.readline().split()))
		b = list(map(int, sys.stdin.readline().split()))
		a.sort()
		b.sort()
		aPos = 0
		bPos = -1
		while k > 0 and aPos < n and (bPos >= -n) and (a[aPos] < b[bPos]):
			(a[aPos], b[bPos]) = (b[bPos], a[aPos])
			if aPos < n - 1 and a[aPos] >= a[aPos + 1]:
				aPos += 1
			if bPos > -n and b[bPos] <= b[bPos - 1]:
				bPos -= 1
			k -= 1
		print(sum(a))
	return
main()


import sys
try:
	sys.stdin = open('Input.txt', 'r')
	sys.stdout = open('Output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for testCases in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	j = 0
	for ind in range(k):
		if a[ind] < b[j]:
			a[ind] = b[j]
			j += 1
	print(sum(a))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		c = min(a)
		d = max(b)
		e = a.index(c)
		f = b.index(d)
		if c < d:
			(c, d) = (d, c)
		a[e] = c
		b[f] = d
	print(sum(a))


t = int(input())
ans = []
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	s = 0
	for i in range(0, k):
		s += max(a[i], b[i])
	for i in range(k, n):
		s += a[i]
	ans.append(s)
for i in range(t):
	print(ans[i])


t = int(input())
for i in range(t):
	(n, k) = iter(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a = list(reversed(sorted(a)))
	b = list(reversed(sorted(b)))
	print(max(map(lambda K: sum(a[:len(a) - K] + b[:K]), list(range(k + 1)))))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	suma = sum(a)
	sumb = sum(b)
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			suma -= a[i]
			suma += b[i]
	print(suma)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	i = 0
	while i <= n - 1 and a[i] < b[n - i - 1] and (k != 0):
		temp = a[i]
		a[i] = b[n - i - 1]
		b[n - i - 1] = temp
		k -= 1
		i += 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))[::-1]
	count = 0
	for i in range(n):
		if i < k:
			count += max(a[i], b[i])
		else:
			count += a[i]
	print(count)


def solve(n, k, a, b):
	a.sort()
	b.sort()
	for i in range(k):
		a[i] = max(a[i], b[n - i - 1])
	return sum(a)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(n, k, a, b))


t = int(input())
for i in range(t):
	l = list(map(int, input().rstrip().split()))
	k = l[1]
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	while k > 0:
		mn = a.index(min(a))
		ma = b.index(max(b))
		if a[mn] < b[ma]:
			temp = a[mn]
			a[mn] = b[ma]
			b[ma] = temp
			k -= 1
		else:
			k = 0
	print(sum(a))


t = int(input())
for i in range(t):
	s = input().split()
	n = int(s[0])
	k = int(s[1])
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(x) for x in input().split()], reverse=True)
	j = 0
	while j < len(a) and b[j] > a[j] and (k > 0):
		(a[j], b[j]) = (b[j], a[j])
		j += 1
		k -= 1
	print(sum(a))


def solve():
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	(l, r) = (0, n - 1)
	ans = sum(a)
	while l < n and r >= 0 and (k > 0):
		if a[l] < b[r]:
			ans += b[r] - a[l]
			k -= 1
			l += 1
			r -= 1
		else:
			break
	print(ans)
for _ in range(int(input())):
	solve()


t = int(input())
SUM = []
for i in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	for q in range(k):
		a.append(max(b))
		b.append(min(a))
		a.remove(min(a))
		b.remove(max(b))
	SUM.append(sum(a))
for i in range(t):
	print(SUM[i])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ai = list(map(int, input().split()))
	bi = list(map(int, input().split()))
	cnt = 0
	for i in range(len(ai)):
		if min(ai) < max(bi) and cnt != k:
			ind1 = ai.index(min(ai))
			ind2 = bi.index(max(bi))
			(ai[ind1], bi[ind2]) = (bi[ind2], ai[ind1])
			bi.pop(ind2)
			cnt += 1
	print(sum(ai))


def sol(a, b, k):
	a = sorted(a)
	b = sorted(b, reverse=True)
	for x in range(k):
		if b[x] > a[x]:
			temp = a[x]
			a[x] = b[x]
			b[x] = temp
	return sum(a)
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	v = sol(a, b, k)
	print(v)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	nn = [int(s) for s in input().split()]
	nnn = [int(s) for s in input().split()]
	nn.sort()
	nnn.sort(reverse=True)
	for l in range(len(nn)):
		if k == 0:
			break
		if nn[l] < nnn[l]:
			nn[l] = nnn[l]
			k -= 1
	print(sum(nn))


import sys
for _ in range(int(input())):
	(n, k) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	a.sort()
	b.sort(reverse=True)
	l = []
	i = 0
	while i < k and b[i] > a[i]:
		l.append(b[i])
		i += 1
	print(sum(l + a[len(l):]))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	while k and min(arr) < max(brr):
		m = min(arr)
		i = arr.index(m)
		mn = max(brr)
		j = brr.index(mn)
		arr[i] = max(brr)
		brr[j] = m
		k -= 1
	print(sum(arr))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if k == 0:
		print(sum(a))
	elif all((i >= max(b) for i in a)) and n == k:
		print(sum(a))
	elif all((i <= min(b) for i in a)) and n == k:
		print(sum(b))
	else:
		while k:
			temp = min(a)
			r = max(b)
			if r > temp:
				a.remove(temp)
				b.remove(r)
				a.append(r)
			k = k - 1
		print(sum(a))
	t = t - 1


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	s = sum(a)
	i = 0
	j = n - 1
	while i < k and a[i] < b[j]:
		s += b[j] - a[i]
		i += 1
		j -= 1
	print(s)


t = int(input())
while t:
	kn = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	res = 0
	for i in range(kn[0]):
		if kn[1] and b[i] > a[i]:
			res += b[i]
			kn[1] -= 1
			continue
		res += a[i]
	print(res)
	t -= 1


def max_sum(lista1, lista2, k, n):
	lista1.sort()
	count = 0
	if k >= n:
		k = n
	for i in range(k):
		if lista1[count] >= max(lista2):
			return sum(lista1)
		else:
			maximum = max(lista2)
			lista2[lista2.index(maximum)] = lista1[count]
			lista1[count] = maximum
			count += 1
	return sum(lista1)
t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	lista1 = input().split()
	lista2 = input().split()
	for j in range(n):
		lista1[j] = int(lista1[j])
		lista2[j] = int(lista2[j])
	print(max_sum(lista1, lista2, k, n))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = [int(x) for x in input().split()]
	br = [int(x) for x in input().split()]
	ar.sort()
	br.sort()
	i = 0
	j = n - 1
	while i < n and j >= 0 and (ar[i] < br[j]) and (k > 0):
		ar[i] = br[j]
		i += 1
		j -= 1
		k -= 1
	sm = 0
	for i in ar:
		sm += i
	print(sm)


t = int(input())
for _ in range(t):
	diff = []
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ans = 0
	for i in range(n):
		if i < k:
			ans += max(a[i], b[i])
		else:
			ans += a[i]
	print(ans)


class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: gcd(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)
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 bisect import bisect_right, bisect_left
from fractions import Fraction

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans
from math import gcd

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

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	i = 0
	j = n - 1
	ans = sum(a)
	for u in range(k):
		if a[i] > b[j]:
			break
		ans += b[j] - a[i]
		i += 1
		j -= 1
	print(ans)


import math
from collections import Counter, deque
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
IN = lambda : input()
mod = 10 ** 9 + 7

def s(a):
	print(' '.join(list(map(str, a))))
for _ in range(I()):
	(n, k) = M()
	a = L()
	b = L()
	x = sorted(a)
	y = sorted(b)
	for i in range(k):
		if y[len(y) - i - 1] >= x[i]:
			(x[i], y[len(y) - i - 1]) = (y[len(y) - i - 1], x[i])
	print(sum(x))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	(coua, coub) = (0, 0)
	sum = 0
	while coua < n:
		if coub < k:
			if b[coub] > a[coua]:
				sum += b[coub]
				coub += 1
			else:
				sum += a[coua]
		else:
			sum += a[coua]
		coua += 1
	print(sum)


from sys import stdin
t = int(stdin.readline())
while t > 0:
	(n, k) = [int(x) for x in stdin.readline().split()]
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	b.sort(reverse=True)
	a.sort()
	summ = 0
	count = 0
	for i in range(n):
		if count < k and a[i] < b[i]:
			summ += b[i]
			count += 1
		else:
			summ += a[i]
	print(summ)
	t -= 1


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().strip().split(' '))
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	a.sort()
	b.sort()
	s = 0
	x = a[0:k] + b[n - k:]
	x.sort()
	s = sum(a[k:]) + sum(x[k:])
	print(s)


for _ in range(int(input())):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	j = 0
	i = 0
	while i != len(a) and m > 0 and (j != len(b)):
		if b[j] > a[i]:
			a[i] = b[j]
			j += 1
			i += 1
			m -= 1
		else:
			i += 1
			j += 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for u in range(k):
		a1 = a.index(min(a))
		b1 = b.index(max(b))
		froma = a[a1]
		fromb = b[b1]
		if froma >= fromb:
			break
		a[a1] = fromb
		b[b1] = froma
	ans = 0
	for j in a:
		ans += j
	print(ans)


import sys
import math
import collections
import bisect

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

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

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(n, k) = get_ints()
	a1 = get_list()
	a2 = get_list()
	a1.sort()
	a2.sort(reverse=True)
	pos = 0
	while k > 0:
		if a1[pos] < a2[pos]:
			a1[pos] = a2[pos]
			k -= 1
			pos += 1
		else:
			break
	print(sum(a1))


for o in range(int(input())):
	x = [int(i) for i in input().split()]
	n = x[0]
	k = x[1]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] > b[n - 1 - i]:
			break
		else:
			a[i] = b[n - 1 - i]
	s = sum(a)
	print(s)


for t in range(int(input())):
	(n, k) = map(int, input().split(' '))
	aa = sorted(list(map(int, input().split(' '))))
	bb = sorted(list(map(int, input().split(' '))))
	for i in range(k):
		if aa[i] < bb[n - 1 - i]:
			(aa[i], bb[n - 1 - i]) = (bb[n - 1 - i], aa[i])
		else:
			break
	print(sum(aa))


T = int(input())
for t in range(T):
	(n, k) = list(map(int, input().strip().split(' ')))
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	a.sort()
	b.sort(reverse=True)
	s = 0
	for i in range(k):
		if a[i] < b[i]:
			s += b[i]
		else:
			s += a[i]
	for i in range(k, n):
		s += a[i]
	print(s)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	m = sorted(list(map(int, input().split())))
	n = sorted(list(map(int, input().split())))
	if m[0] >= n[-1]:
		print(sum(m))
	else:
		p = 0
		q = a - 1
		for j in range(b):
			for k in range(q, -1, -1):
				if n[k] > m[j]:
					(m[j], n[k]) = (n[k], m[j])
					q = k - 1
					p = 1
					break
			if p == 0:
				break
		print(sum(m))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	if k == 0 or a[0] >= b[-1]:
		print(sum(a))
		continue
	j = 0
	i = t = n - 1
	s = 0
	while i >= 0 and t >= 0 and (k > 0) and (j <= t):
		if b[i] > a[t]:
			s += b[i]
			k = k - 1
			i = i - 1
			j += 1
		else:
			s += a[t]
			t = t - 1
	for l in range(j, t + 1):
		s += a[l]
	print(s)


def solve():
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort(reverse=True)
	l2.sort()
	sum1 = 0
	if k == 0:
		print(sum(l1))
		return
	for i in range(k):
		if l1[-1] < l2[-1]:
			l1.pop()
			sum1 += l2[-1]
			l2.pop()
		else:
			break
	v = sum1 + sum(l1)
	print(v)
for _ in range(int(input())):
	solve()


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
sys.setrecursionlimit(10 ** 5)

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

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

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

def solve():
	(n, k) = MI()
	l1 = sorted(LI())
	l2 = LI()
	l2.sort(reverse=True)
	while k != 0:
		if l2[0] > l1[0]:
			l1.remove(l1[0])
			l1.append(l2[0])
			l2.remove(l2[0])
			k -= 1
		else:
			k = 0
	s = 0
	for x in l1:
		s += x
	print(s)
for _ in range(II()):
	solve()


def solve(a1, a2, k, n):
	a1 = sorted(a1)
	a2 = sorted(a2)
	(p1, p2) = (0, n - 1)
	for i in range(k):
		if p1 < n and p2 >= 0 and (a1[p1] < a2[p2]):
			(a1[p1], a2[p2]) = (a2[p2], a1[p1])
			p1 += 1
			p2 -= 1
		else:
			return sum(a1)
	return sum(a1)
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	print(solve(a1, a2, k, n))


T = int(input())
for i in range(T):
	n = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = n[1]
	a1 = [int(i) for i in a]
	a2 = [int(i) for i in b]
	a1.sort()
	a2.sort(reverse=True)
	ans = []
	i = 0
	while i < len(a2) and k:
		if a1[i] > a2[i]:
			ans = ans + a1[i:]
			break
		ans.append(a2[i])
		k -= 1
		i += 1
	if k == 0:
		print(sum(ans) + sum(a1[i:]))
	else:
		print(sum(ans))


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	z = k
	l = sorted(a)
	k = sorted(b)[::-1]
	for i in range(n):
		if z == 0:
			break
		if l[i] < k[i]:
			(k[i], l[i]) = (l[i], k[i])
			z -= 1
	print(sum(l))


a = int(input())
for x in range(a):
	(n, k) = map(int, input().split())
	b1 = list(map(int, input().split()))
	b2 = list(map(int, input().split()))
	for o in range(k):
		if min(b1) < max(b2):
			(b1[b1.index(min(b1))], b2[b2.index(max(b2))]) = (b2[b2.index(max(b2))], b1[b1.index(min(b1))])
	print(sum(b1))


def solve(n, k):
	a = list(map(int, input().split()))
	sa = sum(a)
	b = list(map(int, input().split()))
	while min(a) < max(b) and k:
		k -= 1
		am = 31
		ami = 0
		bm = 0
		bmi = 0
		for i in range(n):
			if a[i] < am:
				ami = i
				am = a[i]
			if b[i] > bm:
				bm = b[i]
				bmi = i
		sa += bm - am
		(a[ami], b[bmi]) = (bm, am)
	return sa
[print(solve(*map(int, input().split()))) for t in range(int(input()))]


t = int(input())
for w in range(t):
	(n, k) = map(int, input().split())
	a = list((int(num) for num in input().strip().split()))
	b = list((int(num) for num in input().strip().split()))
	for x in range(k):
		b.sort()
		if min(a) < b[-(x + 1)]:
			mina = a.index(min(a))
			a[mina] = b[-(x + 1)]
	print(sum(a))


t = int(input())
for t1 in range(t):
	(n, k) = [int(n1) for n1 in input().split()]
	a = [int(n1) for n1 in input().split()]
	b = [int(n1) for n1 in input().split()]
	a = sorted(a)
	b = sorted(b, reverse=True)
	count = 0
	while count < k:
		if a[count] < b[count]:
			a[count] = b[count]
		else:
			break
		count = count + 1
	print(sum(a))


n = int(input())
l = [0] * n
k = [0] * n
a = [0] * n
b = [0] * n
for i in range(n):
	(l[i], k[i]) = map(int, input().split())
	a[i] = list(map(int, input().split()))
	b[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(k[i]):
		if min(a[i]) > max(b[i]):
			continue
		else:
			a[i].append(max(b[i]))
			b[i].append(min(a[i]))
			a[i].remove(min(a[i]))
			b[i].remove(max(b[i]))
	print(sum(a[i]))


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = list(map(int, input().split()))
	t = list(map(int, input().split()))
	s.sort()
	t.sort()
	if s[0] >= t[-1]:
		print(sum(s))
		continue
	for j in range(k):
		if s[0] >= t[-1]:
			break
		a = s.pop(0)
		b = t.pop(-1)
		s.append(b)
		s.sort()
	print(sum(s))


def miheapfy(a1, n1):
	for i in range(n1 // 2 - 1, -1, -1):
		while 2 * i + 1 < n:
			if 2 * i + 2 < n:
				if a1[2 * i + 1] < a1[2 * i + 2]:
					if a1[2 * i + 1] < a1[i]:
						tt = a1[i]
						a1[i] = a1[2 * i + 1]
						a1[2 * i + 1] = tt
						i = 2 * i + 1
					else:
						break
				elif a1[2 * i + 2] < a1[i]:
					tt = a1[i]
					a1[i] = a1[2 * i + 2]
					a1[2 * i + 2] = tt
					i = 2 * i + 2
				else:
					break
			elif 2 * i + 1 < n:
				if a1[2 * i + 1] < a1[i]:
					tt = a1[i]
					a1[i] = a1[2 * i + 1]
					a1[2 * i + 1] = tt
					i = 2 * i + 1
				else:
					break
			else:
				break

def mxheapfy(a1, n1):
	for i in range(n1 // 2 - 1, -1, -1):
		while 2 * i + 1 < n:
			if 2 * i + 2 < n:
				if a1[2 * i + 1] > a1[2 * i + 2]:
					if a1[2 * i + 1] > a1[i]:
						tt = a1[i]
						a1[i] = a1[2 * i + 1]
						a1[2 * i + 1] = tt
						i = 2 * i + 1
					else:
						break
				elif a1[2 * i + 2] > a1[i]:
					tt = a1[i]
					a1[i] = a1[2 * i + 2]
					a1[2 * i + 2] = tt
					i = 2 * i + 2
				else:
					break
			elif 2 * i + 1 < n:
				if a1[2 * i + 1] > a1[i]:
					tt = a1[i]
					a1[i] = a1[2 * i + 1]
					a1[2 * i + 1] = tt
					i = 2 * i + 1
				else:
					break
			else:
				break

def delmi(a1, n):
	te = a1[0]
	a1[0] = a1[n - 1]
	i = 0
	while 2 * i + 1 < n:
		if 2 * i + 2 < n:
			if a1[2 * i + 1] < a1[2 * i + 2]:
				if a1[2 * i + 1] < a1[i]:
					tt = a1[i]
					a1[i] = a1[2 * i + 1]
					a1[2 * i + 1] = tt
					i = 2 * i + 1
				else:
					break
			elif a1[2 * i + 2] < a1[i]:
				tt = a1[i]
				a1[i] = a1[2 * i + 2]
				a1[2 * i + 2] = tt
				i = 2 * i + 2
			else:
				break
		elif 2 * i + 1 < n:
			if a1[2 * i + 1] < a1[i]:
				tt = a1[i]
				a1[i] = a1[2 * i + 1]
				a1[2 * i + 1] = tt
				i = 2 * i + 1
			else:
				break
		else:
			break
	return te

def delma(a1, n):
	te = a1[0]
	a1[0] = a1[n - 1]
	i = 0
	while 2 * i + 1 < n:
		if 2 * i + 2 < n:
			if a1[2 * i + 1] > a1[2 * i + 2]:
				if a1[2 * i + 1] > a1[i]:
					tt = a1[i]
					a1[i] = a1[2 * i + 1]
					a1[2 * i + 1] = tt
					i = 2 * i + 1
				else:
					break
			elif a1[2 * i + 2] > a1[i]:
				tt = a1[i]
				a1[i] = a1[2 * i + 2]
				a1[2 * i + 2] = tt
				i = 2 * i + 2
			else:
				break
		elif 2 * i + 1 < n:
			if a1[2 * i + 1] > a1[i]:
				tt = a1[i]
				a1[i] = a1[2 * i + 1]
				a1[2 * i + 1] = tt
				i = 2 * i + 1
			else:
				break
		else:
			break
	return te
t = int(input())
while t != 0:
	t = t - 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sum1 = sum(a)
	miheapfy(a, n)
	mxheapfy(b, n)
	for i in range(k):
		pp1 = delmi(a, n)
		pp2 = delma(b, n)
		if pp1 >= pp2:
			break
		else:
			sum1 = sum1 - pp1 + pp2
			n = n - 1
	print(sum1)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	ak = a[:k]
	bk = b[-1:-k - 1:-1]
	ak.extend(bk)
	best = sorted(ak)[-1:-k - 1:-1]
	print(sum(a[k:] + best))


import sys
t = int(input())
for i in range(t):
	arg = input().split(' ')
	n = int(arg[0])
	k = int(arg[1])
	a = []
	b = []
	tmp = input().split(' ')
	for j in range(n):
		a.append(int(tmp[j]))
	a.sort()
	tmp = input().split(' ')
	for j in range(n):
		b.append(int(tmp[j]))
	b.sort()
	ans = 0
	ptr_a = 0
	ptr_b = n - 1
	for j in range(k):
		if a[ptr_a] < b[ptr_b]:
			ans += b[ptr_b]
			ptr_b -= 1
		else:
			ans += a[ptr_a]
		ptr_a += 1
	for j in range(k, n):
		ans += a[j]
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	salir = False
	for i in range(k):
		maxb = max(b)
		posmaxb = b.index(maxb)
		for i in range(n):
			if a[i] < maxb:
				(a[i], b[posmaxb]) = (b[posmaxb], a[i])
				break
			if i == n - 1:
				salir = True
		if salir:
			break
	print(sum(a))


from functools import reduce
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[n - i - 1]:
			(a[i], b[n - i - 1]) = (b[n - i - 1], a[i])
	sum = reduce(lambda x, y: x + y, a)
	print(sum)


import sys

def process():
	(n, k) = [int(s) for s in sys.stdin.readline().split()]
	a = [int(s) for s in sys.stdin.readline().split()]
	b = [int(s) for s in sys.stdin.readline().split()]
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < k and a[i] < b[i]:
		(a[i], b[i]) = (b[i], a[i])
		i += 1
	print(sum(a))
T = int(sys.stdin.readline())
for x in range(T):
	process()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = list(map(int, input().split()))
	b = sorted(b, reverse=True)
	j = 0
	ii = 0
	for i in range(m):
		if a[ii] < b[j]:
			a[ii] = b[j]
			ii = ii + 1
			j = j + 1
			if ii == n:
				break
		else:
			j = j + 1
			if j == n:
				break
	print(sum(a))


t = int(input())
i = 0
while i < t:
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort()
	arr2.reverse()
	p = 0
	j = 0
	l = 0
	while p < k and j < len(arr1):
		if arr1[j] < arr2[l]:
			(arr1[j], arr2[l]) = (arr2[l], arr1[j])
			arr2.sort()
			p = p + 1
			arr2.reverse()
		j = j + 1
	print(sum(arr1))
	i = i + 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	la = list(map(int, input().split()))
	lb = list(map(int, input().split()))
	lb.sort(reverse=True)
	la.sort()
	s = sum(la)
	for i in range(k):
		if la[i] < lb[i]:
			s -= la[i] - lb[i]
		else:
			break
	print(s)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		valuea = min(a)
		inda = a.index(valuea)
		valueb = max(b)
		indb = b.index(valueb)
		if valuea <= valueb:
			a[inda] = valueb
			b[indb] = valuea
	print(sum(a))


for t in range(int(input())):
	(n, k) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	s1.sort()
	s2.sort(reverse=True)
	ans = 0
	for i in range(n):
		if i < k:
			ans += max(s1[i], s2[i])
		else:
			ans += s1[i]
	print(ans)


import sys
from math import ceil, sqrt
read = sys.stdin.buffer.readline
mi = lambda : map(int, read().split())
li = lambda : list(mi())
cin = lambda : int(read())

def isp(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
primes = []
for _ in range(cin()):
	(n, k) = mi()
	a = li()
	b = li()
	a.sort()
	b.sort()
	for i in range(n):
		if a[i] < b[n - i - 1] and k > 0:
			a[i] = b[n - i - 1]
			k -= 1
	print(sum(a))


t = int(input())
while t:
	t -= 1
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	summ = sum(a)
	a.sort()
	b.sort(reverse=True)
	for (i, j) in zip(a, b):
		if k > 0:
			k -= 1
			if j > i:
				summ += j - i
			else:
				break
		else:
			break
	print(summ)


t = int(input())
out = []
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	g = 0
	g1 = 0
	while g != k and g1 != len(a):
		if a[g1] < b[0]:
			a[g1] = b[0]
			b.pop(0)
			g = g + 1
			g1 = g1 + 1
		else:
			g1 = g1 + 1
	out.append(sum(a))
for i in range(t):
	print(out[i])


from sys import stdin, stdout, setrecursionlimit
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()], reverse=True)
	for i in range(k):
		if a[i] > b[i]:
			break
		else:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = tuple(map(int, input().split()))
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	j = 0
	while k > 0 and j < n:
		if b[j] > a[j]:
			(a[j], b[j]) = (b[j], a[j])
			k -= 1
		j += 1
	print(sum(a))


t = int(input())
for y in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	a.sort()
	for i in range(n - 1, k - 1, -1):
		ans += a[i]
	b += a[:k]
	b.sort(reverse=True)
	for i in range(k):
		ans += b[i]
	print(ans)


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


T = int(input())
for t in range(T):
	(N, K) = map(int, input().strip().split())
	lst_A = list(map(int, input().split()))
	lst_B = list(map(int, input().split()))
	while K > 0:
		temp = lst_B[lst_B.index(max(lst_B))]
		if lst_B[lst_B.index(max(lst_B))] > lst_A[lst_A.index(min(lst_A))]:
			lst_B[lst_B.index(max(lst_B))] = lst_A[lst_A.index(min(lst_A))]
			lst_A[lst_A.index(min(lst_A))] = temp
		else:
			break
		K -= 1
	print(sum(lst_A))


t = int(input())
ans = [0] * t

def cal():
	s = input().split(' ')
	n = int(s[0])
	k = int(s[1])
	a0 = input().split(' ')
	b0 = input().split(' ')
	a = [0] * n
	b = [0] * n
	for i in range(n):
		(a[i], b[i]) = (int(a0[i]), int(b0[i]))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] <= a[i]:
			break
		a[i] = b[i]
	sm = 0
	for i in range(n):
		sm += a[i]
	return sm
for i in range(t):
	ans[i] = cal()
for i in range(t):
	print(ans[i])


from math import gcd, ceil
from collections import defaultdict as dd

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

def inin():
	return int(input())

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

def ar(element, size):
	return [element for i in range(size)]

def digitsum(num):
	su = 0
	while num:
		su += num % 10
		num //= 10
	return su

def pred(n, k, pointer):
	return pointer - k >= n

def yes():
	print('YES')

def no():
	print('NO')
Testcase = inin()
for _ in range(Testcase):
	(n, k) = inar()
	a = inar()
	b = inar()
	a.sort(reverse=True)
	b.sort(reverse=False)
	su = 0
	su += sum(a[0:n - k])
	a = a[n - k:n]
	a = a + b
	a.sort(reverse=True)
	su += sum(a[0:k])
	print(su)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	while k > 0 and min(A) < max(B):
		B.append(A.pop(A.index(min(A))))
		A.append(max(B))
		B.pop(B.index(max(B)))
		k -= 1
	print(sum(A))


def solve(a, b):
	a = sorted(a)
	b = sorted(b)
	left = k
	sum = 0
	pos_a = 0
	pos_b = n - 1
	for i in range(n):
		if left > 0 and b[pos_b] > a[pos_a]:
			sum += b[pos_b]
			pos_b -= 1
			pos_a += 1
			left -= 1
		else:
			sum += a[pos_a]
			pos_a += 1
	print(sum)
	return
t = int(input())
for i in range(1, t + 1):
	(n, k) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	solve(a, b)


t = int(input())
while t > 0:
	inp = list(map(int, input().split()))
	n = inp[0]
	k = inp[1]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	temp = 0
	while temp < k and a[temp] < b[n - 1 - temp]:
		tempo = a[temp]
		a[temp] = b[n - 1 - temp]
		b[n - 1 - temp] = tempo
		temp += 1
	sum = 0
	for i in range(n):
		sum += a[i]
	print(sum)
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	brr = [int(x) for x in input().split()]
	arr.sort()
	brr.sort()
	for i in range(m):
		if arr[i] < brr[n - i - 1]:
			arr[i] = brr[n - i - 1]
	print(sum(arr))


def ans(l, a, b, k):
	a.sort()
	b.sort()
	b = b[::-1]
	ans = 0
	j = k
	for i in range(l):
		if a[i] < b[i] and k > 0:
			ans += b[i]
			k -= 1
		elif a[i] >= b[i] and k > 0:
			ans += a[i]
			k -= 1
	if k == 0:
		ans += sum(a[j:l + 1])
	return ans
t = int(input())
for i in range(t):
	(l, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(ans(l, a, b, k))


for i in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	tot = 0
	for (ai, bi) in zip(a, b):
		if ai < bi and k > 0:
			tot += bi
			k -= 1
		else:
			tot += ai
	print(tot)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	s = 0
	for i in range(k):
		maxi = max(b)
		mini = min(a)
		if mini < maxi:
			a.remove(mini)
			b.remove(maxi)
			a.append(maxi)
			m = sum(a)
			s = max(m, s)
		else:
			break
	print(sum(a))


def aww(n, k, a, b):
	z = sum(a)
	for i in range(k):
		x = min(a)
		y = max(b)
		a.remove(x)
		a.append(y)
		b.remove(y)
		b.append(x)
		if z > sum(a):
			return z
		z = sum(a)
	return z
	return z
t = int(input())
ans = []
for i in range(t):
	nk = list(map(int, input().rstrip().split()))
	n = int(nk[0])
	k = int(nk[1])
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	result = aww(n, k, a, b)
	ans.append(result)
for i in ans:
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	sum_a = sum(a)
	for i in range(k):
		if a[0] < b[-1]:
			sum_a += b[-1]
			sum_a -= a[0]
			a.append(b[-1])
			a.remove(a[0])
			b.remove(b[-1])
		else:
			break
	print(sum_a)


no = int(input())
for each in range(no):
	(n, k) = map(int, input().split())
	a = input().split()
	b = input().split()
	for each in range(len(a)):
		a[each] = int(a[each])
		b[each] = int(b[each])
	i = 0
	while i < k:
		temp = min(a)
		temp1 = max(b)
		if temp < temp1:
			pos = a.index(temp)
			pos1 = b.index(temp1)
			c = a[pos]
			a[pos] = b[pos1]
			b[pos1] = c
		i += 1
	print(sum(a))


t = int(input())
for c in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	i = 0
	j = 0
	sumi = 0
	while i < n:
		if b[j] > a[i] and k > 0:
			sumi += b[j]
			j += 1
			i += 1
			k -= 1
		else:
			sumi += a[i]
			i += 1
	print(sumi)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(v) for v in input().split()]
	b = [int(v) for v in input().split()]
	a.sort()
	b.sort()
	s = 0
	for j in range(k):
		if a[j] < b[n - j - 1]:
			s = s + b[n - j - 1]
		else:
			s = s + a[j]
	s = s + sum(a[k:])
	print(s)


test = int(input())
while test > 0:
	test = test - 1
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	lia = list(map(int, input().split()))
	lib = list(map(int, input().split()))
	for i in range(k):
		a = min(lia)
		b = max(lib)
		if b >= a:
			lia.remove(a)
			lia.append(b)
			lib.remove(b)
			lib.append(a)
	print(sum(lia))


s = []
for iii in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	b = list(map(int, input().split()))
	b.sort()
	b.reverse()
	g = 0
	for i in range(k):
		g += max(a[i], b[i])
	for i in range(k, n):
		g += a[i]
	s.append(g)
for i in s:
	print(i)


amount = int(input())
for i in range(amount):
	fline = input().split(' ')
	n = int(fline[0])
	k = int(fline[1])
	a = input().split(' ')
	b = input().split(' ')
	a = [int(x) for x in a]
	b = [int(x) for x in b]
	for j in range(k):
		if min(a) == max(b):
			break
		elif min(a) > max(b):
			break
		else:
			amin = min(a)
			a[a.index(min(a))] = max(b)
			b[b.index(max(b))] = amin
	print(sum(a))


import math

def ans(arr1, arr2, k):
	x = sorted(arr1)
	y = sorted(arr2, reverse=True)
	pointera = 0
	pointerb = 0
	while k > 0:
		if x[pointera] <= y[pointerb]:
			(x[pointera], y[pointerb]) = (y[pointerb], x[pointera])
			pointera += 1
			pointerb += 1
		else:
			break
		k -= 1
	return sum(x)
	pass
t = int(input())
while t > 0:
	(n, k) = list(map(int, input().strip().split(' ')))
	arr1 = list(map(int, input().strip().split(' ')))
	arr2 = list(map(int, input().strip().split(' ')))
	print(ans(arr1, arr2, k))
	t -= 1


import sys
input = sys.stdin.readline
import heapq
import copy
import math

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())

class Node:

	def _init_(self, val):
		self.data = val
		self.left = None
		self.right = None

def bin_search(arr, l, r, val):
	if arr[r] <= val:
		return r + 1
	if r - l < 2:
		if arr[l] > val:
			return l
		else:
			return r
	mid = int((l + r) / 2)
	if arr[mid] <= val:
		return bin_search(arr, mid, r, val)
	else:
		return bin_search(arr, l, mid, val)

def pr_list(a):
	print(*a, sep=' ')

def find_permut(hashm, l):
	ans = 1
	total = math.factorial(l)
	for i in hashm:
		if i != 0:
			ans = ans * math.factorial(i)
	return int(total / ans)

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	for test in range(tests):
		[n, k] = inlt()
		a = inlt()
		b = inlt()
		a.sort()
		b.sort()
		l = 0
		r = len(b) - 1
		while k > 0 and l < n and (r >= 0):
			if a[l] < b[r]:
				a[l] = b[r]
				l = l + 1
				r = r - 1
				k = k - 1
			else:
				break
		print(sum(a))
main()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	A = sorted(list(map(int, input().split())))
	B = sorted(list(map(int, input().split())), reverse=True)
	for i in range(k):
		if A[i] > B[i]:
			break
		else:
			(A[i], B[i]) = (B[i], A[i])
	print(sum(A))


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	(n, k) = read_ints()
	a = list(read_ints())
	b = list(read_ints())
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
		else:
			break
	print(sum(a))


from sys import stdin as lector
input = lector.readlines()
for i in range(1, 3 * int(input[0]) + 1, 3):
	(n, k) = list(map(int, input[i].split(' ')))
	a = list(map(int, input[i + 1].split(' ')))
	b = list(map(int, input[i + 2].split(' ')))
	mA = sorted(a, reverse=True)
	mB = sorted(b, reverse=True)
	maximo = sum(a)
	for i in range(0, k + 1):
		maximo = max(maximo, sum(mA[0:n - i] + mB[0:i]))
	print(maximo)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()))
	sm = sum(a)
	i = 0
	while k > 0:
		if b[-1 - i] > a[i]:
			sm = sm + b[-i - 1] - a[i]
		i += 1
		k -= 1
	print(sm)


def check(a, b, k):
	a.sort(reverse=True)
	b.sort(reverse=True)
	count = 0
	p = 0
	i1 = 0
	i2 = 0
	for i in range(len(a)):
		if a[i1] < b[i2] and p < k:
			count += b[i2]
			p += 1
			i2 += 1
		else:
			count += a[i1]
			i1 += 1
	return count
t = int(input())
while t:
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(check(a, b, k))
	t -= 1


def main():
	t = int(input())
	for i in range(t):
		(n, k) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		Max_Sum(n, k, a, b)

def Max_Sum(n, k, a, b):
	a.sort()
	b.sort()
	temp = 0
	i = 0
	l = n - 1
	for j in range(k):
		if a[i] < b[l]:
			temp = a[i]
			a[i] = b[l]
			b[l] = temp
			i += 1
			l -= 1
		else:
			break
	print(sum(a))
main()


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
mod = 1000000007

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

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

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

def printIn(ob):
	return stdout.write(str(ob))

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def myCode():
	(n, k) = In()
	a = L()
	b = L()
	if k == 0:
		print(sum(a))
	else:
		a.sort()
		b.sort()
		for i in range(k):
			if b[::-1][i] > a[i]:
				a[i] = b[::-1][i]
		print(sum(a))

def main():
	for t in range(I()):
		myCode()
main()


t = int(input())
ans = []
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	i = 0
	res = 0
	while i < k:
		if b[n - 1 - i] > a[i]:
			res += b[n - 1 - i]
			i += 1
		else:
			break
	res += sum(a[i:])
	ans.append(str(res))
print('\n'.join(ans))


z = input
n1 = int(z())
for _ in range(n1):
	(n, k) = list(map(int, z().split()))
	lx = []
	l1 = sorted(list(map(int, z().split())))
	l2 = sorted(list(map(int, z().split())))[::-1]
	k1 = 0
	for i in range(n):
		if l1[i] < l2[i] and k1 < k:
			k1 += 1
			l1[i] = l2[i]
		if k1 == k:
			break
	print(sum(l1))


def solve(n, k, a, b):
	aa = sorted(a)
	bb = sorted(b, reverse=True)
	s = k
	if k == 0:
		return sum(a)
	for j in range(k):
		s = j
		if aa[j] >= bb[j]:
			s -= 1
			break
	su = sum(bb[:s + 1]) + sum(aa[s + 1:])
	return su
t = int(input())
for i in range(t):
	(n, k) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(n, k, a, b))


t = int(input())
for _ in range(t):
	nk = str(input()).split(' ')
	n = int(nk[0])
	k = int(nk[1])
	a = str(input()).split(' ')
	b = str(input()).split(' ')
	for e in range(n):
		a[e] = int(a[e])
		b[e] = int(b[e])
	for i in range(k):
		a.append(max(b))
		b.remove(max(b))
		b.append(min(a))
		a.remove(min(a))
	sum = 0
	for j in range(n):
		sum += int(a[j])
	print(sum)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k > 0:
		p = min(a)
		q = max(b)
		if p < q:
			del a[a.index(p)]
			del b[b.index(q)]
			b.append(p)
			a.append(q)
			k -= 1
		else:
			break
	print(sum(a))


t = int(input())
while t > 0:
	t = t - 1
	(n, k) = [int(i) for i in input().split()]
	a = [int(j) for j in input().split()]
	b = [int(k) for k in input().split()]
	a = sorted(a)
	b = sorted(b)
	b = sorted(b)
	sum = 0
	for l in range(k):
		if a[l] < b[n - 1 - l] or a[l] == b[n - 1 - l]:
			a[l] = b[n - 1 - l]
		else:
			continue
	for i in a:
		sum = sum + i
	print(sum)


g = int(input())
while g > 0:
	g = g - 1
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	f = sum(a)
	b.sort(reverse=True)
	a.sort()
	if k == 0:
		print(sum(a))
	elif min(a) >= max(b):
		print(sum(a))
	else:
		for t in range(k):
			if a[t] < b[t]:
				a[t] = b[t]
			else:
				break
		print(sum(a))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	l = [int(i) for i in input().split()]
	m = [int(i) for i in input().split()]
	x = sorted(l)
	y = sorted(m, reverse=True)
	for j in range(b):
		if x[j] < y[j]:
			(x[j], y[j]) = (y[j], x[j])
		else:
			continue
	s = sum(x)
	print(s)


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	i = 0
	s = 0
	while k > 0 and i < n and (a[i] < b[i]):
		s += b[i]
		i += 1
		k -= 1
	while i < n:
		s += a[i]
		i += 1
	return s
for i in range(int(input())):
	print(solve())


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	b = list(map(int, input().split()))
	b = list(reversed(sorted(b)))
	sm = 0
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


def read_int():
	return int(input().strip())

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

def solve():
	(n, k) = read_ints()
	A = read_ints()
	B = read_ints()
	C = [(a, 1) for a in A] + [(b, 0) for b in B]
	C.sort()
	total = 0
	count = 0
	while count < n:
		(e, t) = C.pop()
		if t == 0:
			if k > 0:
				total += e
				k -= 1
			else:
				continue
		else:
			total += e
		count += 1
	return total
T = read_int()
for _ in range(T):
	print(solve())


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().strip().split()]
	b = [int(i) for i in input().strip().split()]
	a.sort()
	b.sort(reverse=True)
	(i, c) = (0, 1)
	while c <= k:
		if a[i] < b[i]:
			a[i] = b[i]
		c += 1
		i += 1
	print(sum(a))


from sys import stdin
inp = stdin.readline
t = int(inp().strip())
while t:
	t -= 1
	(n, k) = [int(k) for k in inp().strip().split()]
	a = [int(k) for k in inp().strip().split()]
	b = [int(k) for k in inp().strip().split()]
	a = sorted(a)
	b = sorted(b)
	temp = n - k
	if temp != 0:
		totalSum = sum(a[-temp:])
	else:
		totalSum = 0
	indexA = -temp - 1 if temp != 0 else -1
	indexB = -1
	for i in range(k):
		if indexA < -n:
			totalSum += b[indexB]
			indexB -= 1
			continue
		if a[indexA] >= b[indexB]:
			totalSum += a[indexA]
			indexA -= 1
		else:
			totalSum += b[indexB]
			indexB -= 1
	print(totalSum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort(reverse=True)
	for i in range(n):
		if k - 1 < i:
			break
		if B[i] > A[i]:
			A[i] = B[i]
	print(sum(A))


t = int(input())
for q in range(t):
	[n, k] = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	i = 0
	c = 0
	while c < k:
		if min(a) < max(b):
			(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
		c += 1
	print(sum(a))


from collections import deque
t = int(input())
rez = []
for i in range(t):
	A = input().split()
	n = int(A[0])
	k = int(A[1])
	a = input().split()
	b = input().split()
	for j in range(n):
		a[j] = int(a[j])
		b[j] = int(b[j])
	sum = 0
	for j in range(n):
		sum += a[j]
	for j in range(k):
		if max(b) > min(a):
			sum -= min(a)
			sum += max(b)
			a.remove(min(a))
			b.remove(max(b))
		else:
			break
	rez.append(sum)
for i in range(len(rez)):
	print(rez[i])


t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	if min(l1) >= max(l2):
		print(sum(l1))
	else:
		while n != 0 and min(l1) < max(l2):
			a = l1.index(min(l1))
			b = l2.index(max(l2))
			(l1[a], l2[b]) = (l2[b], l1[a])
			n -= 1
		print(sum(l1))


t = int(input())
while t > 0:
	t -= 1
	(n, k) = list(map(int, input().split()))
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	i = 0
	j = n - 1
	while k > 0:
		k -= 1
		if a[i] > b[j]:
			break
		(a[i], b[j]) = (b[j], a[i])
		i += 1
		j -= 1
	print(sum(a))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = sorted(list(map(int, input().split())))
	l2 = sorted(list(map(int, input().split())), reverse=True)
	for i in range(k):
		if l2[i] > l1[i]:
			(l1[i], l2[i]) = (l2[i], l1[i])
	print(sum(l1))


def input1(type=int):
	return type(input())

def input2(type=int):
	[a, b] = list(map(type, input().split()))
	return (a, b)

def input3(type=int):
	[a, b, c] = list(map(type, input().split()))
	return (a, b, c)

def input_array(type=int):
	return list(map(type, input().split()))

def input_string():
	s = input()
	return list(s)

def main():
	t = input1()
	for ci in range(t):
		(n, k) = input2()
		a = input_array()
		b = input_array()
		a.sort()
		b.sort(reverse=True)
		for i in range(k):
			if a[i] < b[i]:
				(a[i], b[i]) = (b[i], a[i])
			else:
				break
		print(sum(a))
	return
main()


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().strip().split()))[:n]
	list2 = list(map(int, input().strip().split()))[:n]
	list1.sort()
	list2.sort(reverse=True)
	for (index, element) in enumerate(list1):
		if element >= list2[index] or k == 0:
			break
		elif k != 0:
			(list1[index], list2[index]) = (list2[index], element)
			k -= 1
	print(sum(list1))


r = int(input())
for i in range(r):
	(n, k) = map(lambda x: int(x), input().split())
	num1 = input()
	num2 = input()
	list1 = [int(x) for x in num1.split()]
	list2 = [int(x) for x in num2.split()]
	p = 0
	while p < k:
		a = min(list1)
		b = max(list2)
		if b > a:
			list2.remove(b)
			list2.append(a)
			list1.remove(a)
			list1.append(b)
			p += 1
		else:
			break
	print(sum(list1))


answer = []
for i in range(int(input())):
	count = 0
	(n, k) = list(map(int, input().split()))
	num = list(map(int, input().split()))
	num2 = list(map(int, input().split()))
	num.sort()
	num2.sort()
	if num[0] >= num2[-1] or k == 0:
		count = sum(num)
	else:
		for j in range(n):
			if num[j] < num2[n - j - 1] and k > 0:
				num[j] = num2[n - j - 1]
				k -= 1
			else:
				pass
		count = sum(num)
	answer.append(count)
for i in range(len(answer)):
	if answer[i] == -1:
		print(-1)
	else:
		print(answer[i])


t = int(input())
res = []
for i in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	sum_a = sum(a)
	if k == 0:
		res.append(sum_a)
	else:
		a = sorted(a)
		b = sorted(b, reverse=True)
		i = 0
		while True:
			try:
				if a[i] > b[i] or k == 0:
					break
				else:
					sum_a = sum_a - a[i] + b[i]
				i += 1
				k -= 1
			except IndexError:
				break
		res.append(sum_a)
for i in res:
	print(i)


import math
for w in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
		else:
			break
	print(sum(a))


def Two_arrays(a, b, k):
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	return sum(a)
t = int(input())
for i in range(t):
	line = input().rstrip().split()
	n = int(line[0])
	k = int(line[1])
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	ans = Two_arrays(a, b, k)
	print(ans)
	print('\n')


t = int(input())
while t:
	t = t - 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < n:
		if a[i] > b[0]:
			b.remove(b[0])
		elif a[i] < b[0]:
			if k == 0:
				break
			temp = a[i]
			a[i] = b[0]
			b[0] = temp
			b.sort(reverse=True)
			k = k - 1
		i = i + 1
	print(sum(a))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	br = list(map(int, input().split()))
	ar.sort()
	br.sort()
	for i in range(m):
		if ar[i] < br[n - i - 1]:
			ar[i] = br[n - i - 1]
	print(sum(ar))


for i in range(int(input())):
	n = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ans = 0
	for j in range(n[0]):
		if j < n[1]:
			ans = ans + max(a[j], b[j])
		else:
			ans = ans + a[j]
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		maximum = max(b)
		minimum = min(a)
		if minimum >= maximum:
			break
		a.remove(minimum)
		a.append(maximum)
		b.remove(maximum)
		b.append(minimum)
	print(sum(a))


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	a.sort()
	b.sort()
	b = b[::-1]
	s = sum(a)
	for i in range(k):
		if b[i] > a[i]:
			s += b[i] - a[i]
	print(s)


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	s = 0
	while s < k:
		if a[s] < b[len(b) - 1 - s]:
			a[s] = b[len(b) - 1 - s]
		s += 1
	c = 0
	for j in range(len(a)):
		c += a[j]
	print(c)


MOD = 10 ** 9 + 7
INT_MAX = 10 ** 18 + 7

def INPUT():
	return list((int(i) for i in input().split()))

def LIST_1D_ARRAY(n):
	return [0 for _ in range(n)]

def LIST_2D_ARRAY(m, n):
	return [[0 for _ in range(n)] for _ in range(m)]

def power(a, x):
	res = 1
	while x > 0:
		if x & 1:
			res = res * a % MOD
		a = a * a % MOD
		x //= 2
	return res % MOD

def NCR_MOD(n, r):
	num = 1
	for i in range(n, n - r, -1):
		num = num * i % MOD
	for j in range(1, r + 1):
		num = num * power(j, MOD - 2) % MOD
	return num
import math as M

def calc(n, m):
	if n == 1:
		return 0
	if n == 2:
		return m
	else:
		return 2 * m
for _ in range(int(input())):
	(n, k) = INPUT()
	A = INPUT()
	B = INPUT()
	A.sort()
	B.sort()
	while k > 0:
		if min(A) >= max(B):
			break
		(A[0], B[-1]) = (B[-1], A[0])
		k -= 1
		A.sort()
		B.sort()
	print(sum(A))


N = int(input())
for I in range(N):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	(i, j) = (0, n - 1)
	while k:
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			i += 1
			j -= 1
		k -= 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l_a = list(map(int, input().split()))
	l_b = list(map(int, input().split()))
	l_a.sort()
	l_b.sort()
	sum_a = sum(l_a)
	sum_b = sum(l_b)
	i = 0
	j = n - 1
	while k:
		if sum_a - l_a[i] + l_b[j] > sum_a:
			sum_a = sum_a - l_a[i] + l_b[j]
			i += 1
			j -= 1
		else:
			break
		k -= 1
	print(sum_a)


def solution(a, b, k):
	a.sort()
	b.sort()
	b = b[::-1]
	s = 0
	for i in range(k):
		s += max(a[i], b[i])
	print(s + sum(a[k:]))
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solution(a, b, k)


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b = sorted(b, reverse=True)
	a = sorted(a)
	for i in range(k):
		a[i] = max(a[i], b[i])
	print(sum(a))
	t -= 1


from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')

def solve(n, k, a, b):
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
	return sum(a)
for i in range(int_in()):
	(n, k) = arr_in()
	a = arr_in()
	b = arr_in()
	out(solve(n, k, a, b))


p = int(input())
for z in range(p):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a = sorted(a)
	b = sorted(b)[n - k:]
	for i in range(k):
		for j in range(n):
			if b[k - i - 1] > a[j]:
				a[j] = b[k - i - 1]
				break
	print(sum(a))


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()])
	i = 0
	total = sum(a)
	while k and a[i] < b[n - i - 1]:
		total += b[n - i - 1] - a[i]
		k -= 1
		i += 1
	print(total)


t = int(input())
lst = list()
for p in range(t):
	sum = 0
	(n, m) = input().split()
	a = input().split()
	b = input().split()
	for i in range(len(a)):
		a[i] = int(a[i])
	for i in range(len(b)):
		b[i] = int(b[i])
	a.sort()
	b.sort(reverse=True)
	for i in range(int(m)):
		if b[i] > a[i]:
			a[i] = b[i]
	for i in a:
		sum += i
	lst.append(sum)
for i in lst:
	print(i)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if n == k:
		a.sort()
		b.sort(reverse=True)
		sum_ = 0
		for (i, j) in zip(a, b):
			if i > j:
				sum_ += i
			else:
				sum_ += j
		print(sum_)
	elif k == 0:
		print(sum(a))
	else:
		a.sort()
		b.sort(reverse=True)
		sum_ = 0
		for i in range(k):
			sum_ += max(a[i], b[i])
		for i in range(k, n):
			sum_ += a[i]
		print(sum_)


t = int(input())
while t:
	t -= 1
	(ele_num, swap_times) = map(int, input().split())
	data1 = list(map(int, input().split()))
	data2 = list(map(int, input().split()))
	if swap_times == 0:
		tmp = 0
		for i in data1:
			tmp += i
		print(tmp)
	else:
		data1.sort()
		data2.sort(reverse=True)
		count = 0
		for i in range(swap_times):
			if data2[i] > data1[i]:
				count += 1
		sum1 = 0
		for i in data1[:count]:
			sum1 += i
		sum2 = 0
		for i in data2[:count]:
			sum2 += i
		if sum1 > sum2:
			if ele_num > count:
				tmp = 0
				for i in data1[count:]:
					tmp += i
				print(tmp + sum1)
			else:
				print(sum1)
		elif sum1 == sum2:
			tmp = 0
			for i in data1:
				tmp += i
			print(tmp)
		elif ele_num > count:
			tmp = 0
			for i in data1[count:]:
				tmp += i
			print(tmp + sum2)
		else:
			print(sum2)


import sys, heapq
input = sys.stdin.buffer.readline
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	bb = tuple(map(int, input().split()))
	b = []
	for e in bb:
		b.append(-e)
	heapq.heapify(a)
	heapq.heapify(b)
	for i in range(k):
		if a[0] < -b[0]:
			p = heapq.heappop(a)
			q = heapq.heappop(b)
			heapq.heappush(a, -q)
			heapq.heappush(b, -p)
		else:
			break
	print(sum(a))


t = int(input())
for x in range(t):
	ar = input().split()
	n = int(ar[0])
	k = int(ar[1])
	ar_a = input().split()
	ar_b = input().split()
	int_a = []
	int_b = []
	min_a = 0
	for y in range(len(ar_a)):
		int_a.append(int(ar_a[y]))
		int_b.append(int(ar_b[y]))
	int_a.sort()
	int_b.sort()
	for x in range(k):
		if int_a[x] < int_b[n - 1 - x]:
			int_a[x] = int_b[n - 1 - x]
	for x in range(n):
		min_a += int_a[x]
	print(min_a)


N = int(input())
answers = []
for i in range(N):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	j = 0
	last_ind = len(b) - 1
	while j < k:
		if j >= len(a):
			break
		if a[j] < b[last_ind]:
			temp = a[j]
			a[j] = b[last_ind]
			b[last_ind] = temp
			last_ind -= 1
		elif a[j] == b[last_ind]:
			k += 1
		else:
			break
		j += 1
	answers.append(sum(a))
for i in answers:
	print(i)


t = int(input())
answers = []
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	b.reverse()
	for i in range(k):
		ai = i
		bi = i
		if a[ai] < b[bi]:
			(a[ai], b[bi]) = (b[bi], a[ai])
		else:
			break
	answers.append(sum(a))
print(*answers, sep='\n')


import sys
input = sys.stdin.readline

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

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

def invr():
	return map(int, input().strip().split())
t = inp()
for _ in range(t):
	(n, k) = invr()
	a = inlt()
	b = inlt()
	a.sort()
	b.sort(reverse=True)
	a_min = a[0]
	b_max = b[0]
	if a_min < b_max:
		for i in range(k):
			if a[i] < b[i]:
				a[i] = b[i]
	print(sum(a))


import heapq
import operator

def max_sum(a, b, k):
	if k == 0:
		return sum(a)
	heap_a = a
	heapq.heapify(heap_a)
	heap_b = list(map(operator.neg, list(b)))
	heapq.heapify(heap_b)
	sum_ = 0
	for _ in range(k):
		max_b = -heapq.heappop(heap_b)
		min_a = heap_a[0]
		if max_b <= min_a:
			break
		sum_ += max_b
		heapq.heappop(heap_a)
	sum_ += sum(heap_a)
	return sum_

def main():
	for _ in range(int(input().strip())):
		(n, k) = map(int, input().strip().split(' '))
		a = list(map(int, input().strip().split(' ')))
		b = list(map(int, input().strip().split(' ')))
		print(max_sum(a, b, k))
main()


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ans = sum(a)
	i = 0
	while i < k and a[i] < b[i]:
		ans = ans - a[i] + b[i]
		i += 1
	print(ans)
	t -= 1


import sys
t = int(sys.stdin.readline().split()[0])
for t0 in range(0, t):
	numbers = [int(i) for i in sys.stdin.readline().split()]
	(n, k) = (numbers[0], numbers[1])
	a = [int(i) for i in sys.stdin.readline().split()]
	b = [int(i) for i in sys.stdin.readline().split()]
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < k:
		if b[i] > a[i]:
			a[i] = b[i]
		i += 1
	print(sum(a))


query = int(input())
for i in range(query):
	(size, swaps) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort(reverse=True)
	for j in range(swaps):
		if arr1[j] < arr2[j]:
			(arr1[j], arr2[j]) = (arr2[j], arr1[j])
	sum = 0
	for j in arr1:
		sum += j
	print(sum)


t = int(input())
for z in range(t):
	(n, k) = map(int, input().rstrip().split())
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < k and i < n:
		if b[i] > a[i]:
			a[i] = b[i]
		else:
			break
		i += 1
	print(sum(a))


ans = []
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while max(b) > min(a) and k:
		m = b.index(max(b))
		n = a.index(min(a))
		(b[m], a[n]) = (a[n], b[m])
		k -= 1
	ans.append(sum(a))
for k in ans:
	print(k)


t = int(input())
for i in range(t):
	[n, k] = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	while min(A) < max(B) and k > 0:
		(A[A.index(min(A))], B[B.index(max(B))]) = (B[B.index(max(B))], A[A.index(min(A))])
		k -= 1
	print(sum(A))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	z = sorted(list(map(int, input().split())))
	x = sorted(list(map(int, input().split())))
	(q, w) = (0, 0)
	while b > 0:
		if z[q] < x[-1 - q]:
			w += x[-1 - q] - z[q]
			q += 1
		else:
			break
		b -= 1
	print(sum(z) + w)


a = int(input())
for i in range(a):
	(n, k) = map(int, input().split())
	z = list(map(int, input().split()))
	z.sort()
	m = list(map(int, input().split()))
	m.sort(reverse=True)
	for i in range(k):
		if m[i] > z[i]:
			z[i] = m[i]
	print(sum(z))


import heapq

def solve(n, k, heapa, heapb):
	heapq.heapify(heapa)
	heapq.heapify(heapb)
	while k > 0 and heapa[0] < -heapb[0]:
		aa = heapq.heappop(heapa)
		bb = heapq.heappop(heapb)
		heapq.heappush(heapa, -bb)
		heapq.heappush(heapb, -aa)
		k -= 1
	return sum(heapa)
t = int(input())
for _ in range(t):
	inp = input().split()
	(n, k) = (int(inp[0]), int(inp[1]))
	a = [int(x) for x in input().split()]
	b = [-int(x) for x in input().split()]
	print(solve(n, k, a, b))


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sum_a = sum(a)
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < k and i < n:
		if a[i] >= b[i]:
			break
		sum_a -= a[i]
		sum_a += b[i]
		i += 1
	print(sum_a)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:n]
	sum = 0
	while k:
		pos = b.index(max(b))
		pos2 = a.index(min(a))
		if a[pos2] < b[pos]:
			c = b[pos]
			b[pos] = a[pos2]
			a[pos2] = c
		k -= 1
	for i in range(len(a)):
		sum += a[i]
	print(sum)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	aas = [int(a) for a in input().split()]
	bbs = [int(a) for a in input().split()]
	aas.sort()
	bbs.sort(reverse=True)
	k1 = k
	for i in range(k):
		if aas[i] >= bbs[i]:
			k1 = i
			break
	print(sum(aas[k1:]) + sum(bbs[:k1]))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	l.sort()
	p.sort()
	for j in range(b):
		if l[j] < p[-1]:
			l[j] = p[-1]
			p.remove(p[-1])
	print(sum(l))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	alist = list(map(int, input().split()))
	blist = list(map(int, input().split()))
	alist.sort()
	blist.sort()
	for j in range(n):
		if k == 0:
			break
		if blist[n - j - 1] <= alist[j]:
			break
		if blist[n - j - 1] > alist[j] and k > 0:
			alist[j] = blist[n - j - 1]
			k = k - 1
	print(sum(alist))


for test in range(int(input())):
	(n, k) = map(int, input().split())
	lsta = list(map(int, input().split()))
	lstb = list(map(int, input().split()))
	lsta.sort()
	lstb.sort()
	for i in range(k):
		if lsta[i] < lstb[n - 1 - i]:
			lsta[i] = lstb[n - 1 - i]
		else:
			break
	print(sum(lsta))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	for j in range(k):
		mina = min(a)
		maxb = max(b)
		if mina < maxb:
			(a[a.index(mina)], b[b.index(maxb)]) = (b[b.index(maxb)], a[a.index(mina)])
	print(sum(a))


import functools
C = []
t = int(input())
for j in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	A = sorted(a)
	B = sorted(b)
	for i in range(k):
		if A[i] >= B[n - i - 1]:
			break
		else:
			(a[a.index(A[i])], b[b.index(B[n - i - 1])]) = (b[b.index(B[n - i - 1])], a[a.index(A[i])])
	C.append(str(functools.reduce(lambda x, y: x + y, a)))
for i in C:
	print(int(i))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	aInput = input()
	a = list(map(int, aInput.split()))
	bInput = input()
	b = list(map(int, bInput.split()))
	while k > 0:
		a.sort()
		b.sort()
		if a[0] < b[n - 1]:
			(a[0], b[n - 1]) = (b[n - 1], a[0])
		k -= 1
	sumOfa = sum(a)
	print(sumOfa)


t = int(input())
for t in range(t):
	(n, k) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	for i in range(k):
		aMin = min(a)
		bMax = max(b)
		if bMax > aMin:
			(a[a.index(aMin)], b[b.index(bMax)]) = (b[b.index(bMax)], a[a.index(aMin)])
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k:
		t1 = max(b)
		t2 = min(a)
		if t1 > t2:
			(a[a.index(t2)], b[b.index(t1)]) = (b[b.index(t1)], a[a.index(t2)])
		k -= 1
	print(sum(a))


t = int(input())
result = []
for i in range(t):
	nk = list(map(int, input().split()))
	n = nk[0]
	k = nk[-1]
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	for i in range(k):
		c = a[i]
		if a[i] < b[i]:
			a[i] = b[i]
			b[i] = c
	result.append(sum(a))
for i in result:
	print(i)


R = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, k) = R()
	(a, b) = (sorted(R()), sorted(R()))
	s = 0
	for (idx, i) in enumerate(a):
		if idx < k and b[-1 - idx] > i:
			s += b[-1 - idx]
		else:
			s += i
	print(s)


def solve(n, k, a, b):
	profit = 0
	a.sort()
	b.sort()
	front = 0
	end = n - 1
	while front < n and end >= 0 and (a[front] <= b[end]) and (k > 0):
		k -= 1
		profit += b[end] - a[front]
		end -= 1
		front += 1
	return sum(a) + profit

def main():
	t = int(input())
	for i in range(t):
		d = input()
		d = [int(i) for i in d.split()]
		n = d[0]
		k = d[1]
		e = input()
		e = [int(j) for j in e.split()]
		f = input()
		f = [int(k) for k in f.split()]
		ans = solve(n, k, e, f)
		print(ans)
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(a)
	while k > 0:
		s = sum(a)
		g = min(a)
		a.remove(g)
		b.append(g)
		s -= g
		m = max(b)
		a.append(m)
		b.remove(m)
		s += m
		k -= 1
	print(s)


for T in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	if min(a) >= max(b):
		print(sum(a))
	else:
		for i in range(k):
			(maximum, minimum) = (-1, 31)
			(pos_max, pos_min) = (0, 0)
			for i in range(n):
				if a[i] < minimum:
					minimum = a[i]
					pos_min = i
				if b[i] > maximum:
					maximum = b[i]
					pos_max = i
			if maximum > minimum:
				(a[pos_min], b[pos_max]) = (b[pos_max], a[pos_min])
		print(sum(a))


n = int(input())
for _ in range(n):
	(n, k) = map(int, input().split())
	lista = list(map(int, input().split()))
	listb = list(map(int, input().split()))
	for _ in range(k):
		mina = min(lista)
		maxb = max(listb)
		if mina < maxb:
			inda = lista.index(mina)
			indb = listb.index(maxb)
			(lista[inda], listb[indb]) = (listb[indb], lista[inda])
	print(sum(lista))


testcases = int(input())
for testcase in range(testcases):
	ty = input()
	arr = ty.split()
	n = int(arr[0])
	m = int(arr[1])
	ty = input()
	temp = ty.split()
	a_arr = []
	for i in temp:
		a_arr.append(int(i))
	ty = input()
	a_arr = sorted(a_arr)
	temp = ty.split()
	b_arr = []
	for i in temp:
		b_arr.append(int(i))
	b_arr = sorted(b_arr)
	b_pointer = n - 1
	a_pointer = 0
	while m and a_pointer <= n and (b_pointer >= 0):
		if a_arr[a_pointer] > b_arr[b_pointer]:
			break
		if a_arr[a_pointer] == b_arr[b_pointer]:
			break
			continue
		else:
			a_arr[a_pointer] = b_arr[b_pointer]
			a_pointer += 1
			m -= 1
			b_pointer -= 1
	print(sum(a_arr))


def nod(a, b):
	while a != b:
		(a, b) = (max(a, b), min(a, b))
		if a % b == 0:
			a -= (a // b - 1) * b
		else:
			a -= a // b * b
	return a
for t in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = list(sorted([int(x) for x in input().split()]))
	b = list(reversed(sorted([int(x) for x in input().split()])))
	for i in range(k):
		if a[i] > b[i]:
			break
		a[i] = b[i]
	print(sum(a))


import math
from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	total = sum(a)
	for i in range(k):
		if a[i] >= b[i]:
			break
		total = total - a[i] + b[i]
	print(total)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	total = []
	total.append(sum(a))
	for i in range(k):
		c = min(a)
		d = max(b)
		(a[a.index(c)], b[b.index(d)]) = (d, c)
		total.append(sum(a))
	print(max(total))


from sys import stdin
import math
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in range(k):
		if max(b) > min(a):
			swap = b[b.index(max(b))]
			b[b.index(max(b))] = a[a.index(min(a))]
			a[a.index(min(a))] = swap
	print(sum(a))


i = 0
t = int(input())
while i < t:
	(n, k) = map(int, input().split())
	a = [int(item) for item in input().split()]
	b = [int(item) for item in input().split()]
	a.sort()
	b.sort(reverse=True)
	ans = 0
	for j in range(n):
		if j < k:
			ans += max(a[j], b[j])
		else:
			ans += a[j]
	print(ans)
	i += 1


from collections import deque

def b():
	(n, k) = map(int, input().split())
	a = deque(map(int, input().split()))
	b = deque(map(int, input().split()))
	for _ in range(k):
		maior_b = max(b)
		menor_a = min(a)
		indice_menor_a = a.index(menor_a)
		if maior_b > menor_a:
			a[indice_menor_a] = maior_b
			b.remove(maior_b)
	print(sum(a))

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


def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a.sort()
		b.sort(reverse=True)
		for i in range(n):
			for j in range(n):
				if a[i] < b[j] and k > 0:
					(a[i], b[j]) = (b[j], a[i])
					b.sort(reverse=True)
					k -= 1
				if k == 0:
					break
		print(sum(a))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	liA = sorted(list(map(int, input().split())))
	liB = sorted(list(map(int, input().split())), reverse=True)
	s = sum(liA)
	for i in range(k):
		if liB[i] > liA[i]:
			s += liB[i] - liA[i]
	print(s)


def swap(a, b):
	temp = a
	a = b
	b = temp
t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ls = list(map(int, input().split()))
	l.sort()
	ls.sort()
	ls = ls[::-1]
	for i in range(k):
		if l[i] < ls[i]:
			temp = l[i]
			l[i] = ls[i]
			ls[i] = temp
		else:
			pass
	print(sum(l))


for g in range(int(input())):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a = sorted(a)
	b = sorted(b)
	b = b[::-1]
	i = 0
	j = 0
	s = 0
	while i < len(a):
		if j < k and a[i] > b[j]:
			s += a[i]
			i += 1
			continue
		if j < k:
			s += b[j]
			j += 1
			i += 1
			continue
		if i < len(a):
			s += a[i]
			i += 1
	print(s)


from sys import stdin
input = stdin.readline

def main():
	test = int(input())
	for t in range(test):
		l = [int(i) for i in input().split(' ')]
		n = l[0]
		k = l[1]
		a = [int(i) for i in input().split(' ')]
		b = [int(i) for i in input().split(' ')]
		b.sort(reverse=True)
		a.sort()
		l = [0 for i in range(n)]
		i = n - 1
		j = 0
		c = 0
		s = 0
		while i >= 0 and j < n and (k > 0) and (c < n):
			if a[i] < b[j]:
				l[c] = b[j]
				j += 1
				k -= 1
			else:
				l[c] = a[i]
				i -= 1
			c += 1
		while i >= 0 and c < n:
			l[c] = a[i]
			i -= 1
			c += 1
		print(sum(l))
main()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	x = a[:k]
	s = 0
	for i in range(0, k):
		x.append(b[n - k + i])
	x.sort(reverse=True)
	s = sum(x[:k]) + sum(a[k:])
	print(s)


testcases = int(input())
for i in range(testcases):
	(n, k) = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	y = True
	for i in range(k):
		if min(arr1) < max(arr2):
			temp = arr1[arr1.index(min(arr1))]
			arr1[arr1.index(min(arr1))] = arr2[arr2.index(max(arr2))]
			arr2[arr2.index(max(arr2))] = temp
		else:
			print(sum(arr1))
			y = False
			break
	if y:
		print(sum(arr1))


def solve():
	t = int(input())
	for i in range(t):
		(n, k) = [int(s) for s in input().split()]
		a = sorted([int(s) for s in input().split()])
		b = sorted([int(s) for s in input().split()], reverse=True)
		for j in range(k):
			if a[j] <= b[j]:
				a[j] = b[j]
		print(sum(a))

def __starting_point():
	solve()
__starting_point()


from sys import stdin, exit
input = stdin.readline

def i():
	return input()

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

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

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

def print_array(a):
	print(' '.join(map(str, a)))
t = ii()
for _ in range(t):
	(n, k) = iis()
	a = liis()
	b = liis()
	a = sorted(a)
	b = sorted(b)[::-1]
	i = 0
	while i < n and a[i] < b[i] and (k > 0):
		(a[i], b[i]) = (b[i], a[i])
		i += 1
		k -= 1
	print(sum(a))


T = int(input())
for each in range(1, T + 1):
	(n, k) = input().split()
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	for num in range(int(k)):
		if min(a) > max(b):
			break
		else:
			temp = a[0]
			a[0] = b[int(n) - 1]
			b[int(n) - 1] = temp
			a.sort()
			b.sort()
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	li = []
	f = 0
	count = 0
	i = 0
	while i < n and count < k:
		if a[i] <= b[i]:
			if a[i] < b[i]:
				count += 1
			li.append(b[i])
		else:
			f = 1
			break
		i += 1
	if li == []:
		ans = sum(a)
	else:
		ans = sum(li) + sum(a[i:])
	print(ans)


def solution(a, b, moves):
	a.sort()
	b.sort()
	(L, R) = (0, len(b) - 1)
	while moves:
		if a[L] < b[R]:
			a[L] = b[R]
			L += 1
			R -= 1
		moves -= 1
	return sum(a)
import sys
iput = sys.stdin.readline
for x in range(int(iput())):
	i = list(map(int, iput().split()))
	(n, k) = (i[0], i[1])
	A = list(map(int, iput().split()))
	B = list(map(int, iput().split()))
	print(solution(A, B, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	b = list(map(int, input().split()))[:n]
	for i in range(k):
		if min(a) <= max(b):
			mina = min(a)
			maxb = max(b)
			c = a.index(mina)
			d = b.index(maxb)
			(a[c], b[d]) = (b[d], a[c])
	print(sum(a))


def fun(l, arr1, arr2, k):
	sum = 0
	arr1.sort()
	arr2.sort(reverse=True)
	for i in range(0, k):
		x = arr1.index(min(arr1))
		y = arr2.index(max(arr2))
		if min(arr1) < max(arr2):
			temp = arr1[x]
			arr1[x] = arr2[y]
			arr2[y] = temp
	for i in range(0, l):
		sum = sum + arr1[i]
	print(sum)
	return
for i in range(0, int(input())):
	(l, k) = [int(x) for x in input().split()]
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(x) for x in input().split()]
	fun(l, arr1, arr2, k)


for i in range(int(input())):
	(n, k) = [int(num) for num in input().split()]
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(y) for y in input().split()]
	arr1.sort()
	arr2.sort(reverse=True)
	for j in range(k):
		if arr1[j] < arr2[j]:
			arr1[j] = arr2[j]
			k -= 1
		else:
			break
	print(sum(arr1))


t = int(input())
for _ in range(t):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	a = list(input().split(' '))
	A = [int(x) for x in a]
	b = list(input().split(' '))
	B = [int(x) for x in b]
	A.sort(reverse=True)
	B.sort(reverse=True)
	mn = A[-1]
	mx = B[0]
	while mn < mx and k > 0:
		A.pop(-1)
		A.append(mx)
		A.sort(reverse=True)
		mn = A[-1]
		B.pop(0)
		if len(B) == 0:
			break
		mx = B[0]
		k -= 1
	sm = 0
	for i in range(len(A)):
		sm += A[i]
	print(sm)


I = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, k) = I()
	arr1 = sorted(I())
	arr2 = sorted(I())
	(i, j, s) = (0, 0, len(arr2) - 1)
	while i < k:
		if arr1[j] >= arr2[s]:
			break
		(arr1[j], arr2[s]) = (arr2[s], arr1[j])
		j += 1
		s -= 1
		i += 1
	print(sum(arr1))


test = int(input())
for _ in range(test):
	(n, k) = map(int, input().split())
	list1 = [int(z) for z in input().split()]
	list2 = [int(z) for z in input().split()]
	for t in range(k):
		if min(list1) < max(list2):
			list1[list1.index(min(list1))] = max(list2)
			list2.remove(max(list2))
		else:
			break
	print(sum(list1))


def solution(n, k):
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	ans = 0
	counter = 0
	for i in range(n):
		if counter < k:
			ans += max(a[i], b[n - i - 1])
		else:
			ans += a[i]
		counter += 1
	return ans
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	print(solution(n, m))


for ii in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	if max(b) > min(a):
		i = 0
		while k > 0 and max(b) > min(a):
			x = b.index(max(b))
			(a[i], b[x]) = (b[x], a[i])
			i += 1
			k -= 1
		print(sum(a))
	else:
		print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = list([int(x) for x in input().split()])
	b = list([int(x) for x in input().split()])
	a.sort()
	b.sort()
	l = 0
	r = n - 1
	c = 0
	while l < n and r >= 0 and (a[l] < b[r]) and (c < k):
		tmp = a[l]
		a[l] = b[r]
		b[r] = tmp
		l += 1
		r -= 1
		c += 1
	print(sum(a))


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()][:n]
	b = [int(i) for i in input().split()][:n]
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[n - i - 1]:
			(a[i], b[n - i - 1]) = (b[n - i - 1], a[i])
		else:
			break
	sum = 0
	for i in a:
		sum += i
	print(sum)


def swap(x, y):
	pointer = x[0]
	x[0] = y[n - 1]
	y[n - 1] = pointer
	x.sort()
	y.sort()
for _ in [0] * int(input()):
	(n, k) = list(map(int, input().split()))
	A = sorted(list(map(int, input().split())))
	B = sorted(list(map(int, input().split())))
	for item in range(k):
		if A[0] >= B[n - 1]:
			break
		else:
			swap(A, B)
	print(sum(A))


t = int(input())
for t1 in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	i = 0
	j = 0
	sum = 0
	kb = 0
	while i + j < len(a):
		if kb < k and b[j] > a[i]:
			kb += 1
			sum += b[j]
			j += 1
		else:
			sum += a[i]
			i += 1
	print(sum)


def parse_input(inp):
	inp = inp.split()
	return [int(x) for x in inp]

def solve(k, a, b):
	cum_sum = sum(a)
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			cum_sum += b[i] - a[i]
	print(cum_sum)

def main():
	t = int(input())
	for i in range(t):
		k = parse_input(input())[1]
		a = parse_input(input())
		b = parse_input(input())
		solve(k, a, b)
main()


from sys import stdin
N = int(stdin.readline())
for case in range(N):
	(n, k) = map(int, stdin.readline().split())
	array1 = list(map(int, stdin.readline().split()))
	array2 = list(map(int, stdin.readline().split()))
	anssum = sum(array1)
	for swap in range(k):
		if min(array1) >= max(array2):
			break
		else:
			anssum += max(array2) - min(array1)
			(array1[array1.index(min(array1))], array2[array2.index(max(array2))]) = (max(array2), min(array1))
	print(anssum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = sorted(list(map(int, input().split())))
	x = sorted(list(map(int, input().split())))
	x.reverse()
	for i in range(k):
		if x[i] > l[i]:
			l[i] = x[i]
	print(sum(l))


for u in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	d = list(map(int, input().split()))
	l.sort()
	s = 0
	d.sort(reverse=True)
	for i in range(n):
		if m > 0 and d[i] > l[i]:
			s = s + d[i]
			m = m - 1
		else:
			s = s + l[i]
	print(s)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort(reverse=True)
	for x in range(a):
		if b == 0:
			break
		if l1[x] < l2[x]:
			l1[x] = l2[x]
			b -= 1
	print(sum(l1))


from collections import Counter
from collections import defaultdict
from collections import deque
import math
import sys
input = sys.stdin.readline
import bisect
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rls = lambda : list(map(str, input().split()))
t = int(input())
for _ in range(0, t):
	(n, k) = list(map(int, input().split()))
	a = rl()
	b = rl()
	a.sort()
	b.sort(reverse=True)
	j = 0
	for i in range(0, n):
		if k == 0:
			break
		if a[i] < b[i]:
			a[i] = b[i]
			k = k - 1
		else:
			break
	print(sum(a))


def solve():
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	(i, j) = (0, 0)
	while i < n and k:
		if a[i] < b[j]:
			a[i] = b[j]
			j += 1
			k -= 1
		i += 1
	print(sum(a))
for _ in range(int(input())):
	solve()


import sys
input = lambda : sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline

def I():
	return list(map(int, inp().split()))
from heapq import *
for _ in range(I()[0]):
	(n, k) = I()
	a = I()
	b = I()
	for i in range(k):
		z1 = min(a)
		z2 = max(b)
		zind1 = a.index(z1)
		zind2 = b.index(z2)
		if z2 > z1:
			(a[zind1], b[zind2]) = (b[zind2], a[zind1])
		else:
			break
	print(sum(a))


t = int(input())
output = []
for i in range(t):
	count = 0
	(n, k) = map(int, input().split())
	a = [0] * n
	b = [0] * n
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for j in range(n):
		for m in range(n):
			if a[j] < b[m] and count < k:
				(a[j], b[m]) = (b[m], a[j])
				count += 1
				break
	output.append(sum(a))
for i in range(t):
	print(output[i])


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	cou = 0
	for j in range(n):
		if a[j] < b[cou] and cou < k:
			tamp = a[j]
			a[j] = b[cou]
			b[cou] = tamp
			cou += 1
			if cou == k:
				break
	print(sum(a))


for case in range(int(input())):
	(length, switch) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if switch == 0:
		print(sum(a))
	else:
		for i in range(switch):
			if min(a) < max(b):
				a.append(max(b))
				b.remove(max(b))
				a.remove(min(a))
			elif min(a) >= max(b):
				break
		print(sum(a))


def bubbleSort(arr1, arr2):
	n = len(arr1)
	for i in range(n - 1):
		for j in range(0, n - i - 1):
			if arr1[j] > arr1[j + 1]:
				(arr1[j], arr1[j + 1]) = (arr1[j + 1], arr1[j])
			if arr2[j] > arr2[j + 1]:
				(arr2[j], arr2[j + 1]) = (arr2[j + 1], arr2[j])
for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	bubbleSort(a, b)
	sum = 0
	s = 0
	for i in range(n):
		if s >= k:
			sum = sum + a[i]
			continue
		if a[i] < b[n - i - 1]:
			a[i] = b[n - i - 1]
			s = s + 1
		sum = sum + a[i]
	print(sum)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if k == 0:
		print(sum((x for x in a)))
	else:
		for j in range(k):
			maxi = max(b)
			mini = min(a)
			if maxi > mini:
				a.remove(mini)
				a.append(maxi)
				b.remove(maxi)
				b.append(mini)
		print(sum((x for x in a)))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	for _ in range(k):
		(b, bi) = (-1, -1)
		(s, si) = (float('inf'), -1)
		for i in range(n):
			if A[i] < s:
				s = A[i]
				si = i
			if B[i] > b:
				b = B[i]
				bi = i
		if b > s:
			A[si] = b
			B[bi] = s
	print(sum(A))


from sys import stdin, stdout
for testcases in range(int(stdin.readline())):
	(n, m) = map(int, stdin.readline().split())
	arr1 = list(map(int, stdin.readline().split()))
	arr2 = list(map(int, stdin.readline().split()))
	arr1.sort()
	arr2.sort(reverse=True)
	i = 0
	j = 0
	while i < n and j < n:
		if arr1[i] >= arr2[j] or m == 0:
			break
		arr1[i] = arr2[j]
		i += 1
		j += 1
		m -= 1
		if m == 0:
			break
	stdout.write(str(sum(arr1)) + '\n')


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

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
import sys
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	if k == 0:
		print(sum(l1))
		continue
	for i in range(n):
		maxi = 0
		flag = -1
		for j in range(n):
			if l1[i] < l2[j]:
				maxi = max(maxi, l2[j])
				if l2[j] == maxi:
					flag = j
		if maxi != 0:
			l2[flag] = l1[i]
			l1[i] = maxi
			k -= 1
		if k == 0:
			break
	print(sum(l1))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=1)
	ans = 0
	for i in range(k + 1):
		ans = max(ans, sum(a[i:]) + sum(b[:i]))
	print(ans)


t = int(input(''))
for i in range(t):
	s1 = input('')
	L = s1.split(' ')
	(n, k) = (int(L[0]), int(L[1]))
	a1 = input('')
	a = a1.split(' ')
	b1 = input('')
	b = b1.split(' ')
	for j in range(n):
		a[j] = int(a[j])
		b[j] = int(b[j])
	a.sort()
	b.sort()
	for j in range(k):
		if a[j] <= b[n - j - 1]:
			a[j] = b[n - j - 1]
	sums = 0
	for j in range(n):
		sums += a[j]
	print(sums)


n = int(input())
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	s = list(map(int, input().split()))
	t = list(map(int, input().split()))
	s.sort()
	t.sort()
	for i in range(b):
		if s[i] < t[len(t) - 1 - i]:
			x = s[i]
			s[i] = t[len(t) - 1 - i]
			t[len(t) - 1 - i] = x
	print(sum(s))


a = int(input())
for i in range(a):
	(b, c) = input().split()
	(b, c) = (int(b), int(c))
	s = 0
	p = input().split()
	o = input().split()
	for j in range(b):
		p[j] = int(p[j])
		o[j] = int(o[j])
	for j in range(c):
		if min(p) > max(o):
			break
		f = min(p)
		p[p.index(min(p))] = o[o.index(max(o))]
		o[o.index(max(o))] = f
	for j in range(b):
		s += int(p[j])
	print(s)


t = int(input())
for i in range(t):
	m = 0
	n = [int(s) for s in input().split()]
	a = [int(s) for s in input().split()]
	a.sort()
	b = [int(s) for s in input().split()]
	b.sort()
	for j in range(n[1]):
		if a[j] < b[n[0] - j - 1]:
			temp = a[j]
			a[j] = b[n[0] - j - 1]
			b[n[0] - j - 1] = temp
	for i in range(n[0]):
		m = m + a[i]
	print(m)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	pa = 0
	pb = n - 1
	for i in range(k):
		if a[pa] < b[pb]:
			a[pa] = b[pb]
			pa += 1
			pb -= 1
		else:
			break
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	c = []
	for i in range(n):
		c.append(b[i] - a[i])
	j = 0
	s1 = 0
	while j < k and c[j] > 0:
		s1 += c[j]
		j += 1
	print(s1 + sum(a))


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 math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush

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

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

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

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

def main():
	for _ in range(N()):
		(n, k) = RL()
		arra = RLL()
		arrb = RLL()
		arrb.sort(reverse=1)
		arra = arra + arrb[:k]
		arra.sort(reverse=1)
		print(sum(arra[:n]))
main()


t = int(input())
answers = list()
for i in range(t):
	(n, k) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	for j in range(k):
		min_a = min(a)
		max_b = max(b)
		if min_a < max_b:
			a.remove(min_a)
			b.remove(max_b)
			a.append(max_b)
		else:
			pass
	answers.append(sum(a))
for i in answers:
	print(i)


for _ in range(int(input())):
	s = input().split()
	(n, k) = (int(s[0]), int(s[1]))
	a = list(map(int, input().split()))
	a.sort()
	b = list(map(int, input().split()))
	b.sort()
	l = 0
	r = n - 1
	while k > 0:
		if a[l] < b[r]:
			(a[l], b[r]) = (b[r], a[l])
			l += 1
			r -= 1
			k -= 1
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = []
	s = 0
	for el in map(int, input().split()):
		a.append(el)
		s += el
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	while i < n and k and (j >= 0):
		if a[i] < b[j]:
			s += b[j] - a[i]
			i += 1
			j -= 1
			k -= 1
		else:
			break
	print(s)


import sys
from queue import PriorityQueue
import heapq
import math
t = int(sys.stdin.readline().rstrip())
for T in range(t):
	(n, k) = map(int, sys.stdin.readline().rstrip().split())
	a = list(map(int, sys.stdin.readline().rstrip().split()))
	b = list(map(int, sys.stdin.readline().rstrip().split()))
	a = [(i, i) for i in a]
	b = [(-i, i) for i in b]
	heapq.heapify(a)
	heapq.heapify(b)
	for i in range(k):
		one = heapq.heappop(a)[1]
		two = heapq.heappop(b)[1]
		if one >= two:
			heapq.heappush(a, (one, one))
			heapq.heappush(b, (-two, two))
			break
		heapq.heappush(a, (two, two))
		heapq.heappush(b, (-one, one))
	a = [j for (i, j) in a]
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	l = len(b) - 1
	ans = 0
	for i in range(k):
		if a[i] < b[l - i]:
			ans += b[l - i]
		else:
			ans += a[i]
	s = sum(a[k:])
	ans += s
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	t1 = 0
	for i in range(n):
		if k > 0:
			if b[i] > a[i]:
				t1 += b[i]
			else:
				t1 += a[i]
		else:
			t1 += a[i]
		k -= 1
	print(t1)


def rn():
	a = int(input())
	return a

def rl():
	a = list(map(int, input().split()))
	return a
for _ in range(int(input())):
	[n, k] = rl()
	a = rl()
	b = rl()
	a.sort()
	b.sort(reverse=True)
	for i in range(0, k):
		if a[i] > b[i]:
			b[i] = a[i]
	ans = sum(b[:k] + a[k:])
	print(ans)


def swap_sum(a: list, b: list, k: int) -> int:
	for i in range(k):
		if max(b) > min(a):
			(b[b.index(max(b))], a[a.index(min(a))]) = (a[a.index(min(a))], b[b.index(max(b))])
			k -= 1
		else:
			break
	return sum(a)
t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ans = swap_sum(a, b, k)
	print(ans)
	t -= 1


def func(zipped):
	(n, k) = list(map(int, zipped[0].split()))
	a = list(map(int, zipped[1].split()))
	b = list(map(int, zipped[2].split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	mix = a + b
	mix.sort(reverse=True)
	get = mix[:n]
	filtered = []
	for i in get:
		if i in a:
			filtered.append(i)
			a.remove(i)
	if len(filtered) == n:
		pass
	else:
		filtered += b[:k]
		filtered += a[:n - len(filtered)]
	return sum(filtered[:n])

def main():
	t = int(input())
	nk = []
	a_list = []
	b_list = []
	for i in range(t):
		nk.append(input())
		a_list.append(input())
		b_list.append(input())
	zipped = zip(nk, a_list, b_list)
	result = map(func, zipped)
	for i in result:
		print(i)
main()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(a) for a in input().split()]
	a.sort()
	b = [int(b) for b in input().split()]
	b.sort(reverse=True)
	if a[0] > b[0]:
		print(sum(a))
	else:
		for j in range(k):
			if a[j] <= b[j]:
				a[j] = b[j]
			else:
				break
		print(sum(a))


t = int(input())
for r in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(a)
	x = min(a)
	y = max(b)
	z = 0
	for i in range(k):
		x = min(a)
		y = max(b)
		if x < y:
			s = s - x + y
			del a[a.index(x)]
			del b[b.index(y)]
	print(s)


test = int(input())
for _ in range(0, test):
	(n, k) = map(int, input().split())
	a = [int(num) for num in input().split()]
	b = [int(num) for num in input().split()]
	a.sort()
	b.sort()
	for idx in range(0, min(n, k)):
		if a[idx] < b[n - idx - 1]:
			(a[idx], b[n - idx - 1]) = (b[n - idx - 1], a[idx])
		else:
			break
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	a = list((int(num) for num in input().split(' ')))[:n]
	b = list((int(num) for num in input().split(' ')))[:n]
	while k > 0:
		if max(b) > min(a):
			ib = b.index(max(b))
			ia = a.index(min(a))
			t = min(a)
			a[ia] = b[ib]
			b[ib] = t
			k -= 1
		else:
			break
	print(sum(a))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sorted_a = sorted(a)
	sorted_b = sorted(b, reverse=True)
	i = 0
	diff = 0
	summ = sum(a)
	while i < n and k != 0:
		if sorted_a[i] < sorted_b[i]:
			diff += sorted_b[i] - sorted_a[i]
			k -= 1
		i += 1
	print(diff + summ)
	t -= 1


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


def solve():
	(n, k) = map(int, input().split())
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l1.sort()
	l2.sort(reverse=True)
	ans = 0
	for i in range(k):
		ans += max(l1[i], l2[i])
	print(ans + sum(l1[k:]))
try:
	for _ in range(int(input())):
		solve()
except:
	pass


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


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	c = sorted(map(int, input().split()))
	d = sorted(map(int, input().split()), reverse=True)
	i = 0
	while i < a and b:
		if c[i] < d[i]:
			c[i] = d[i]
			b -= 1
		i += 1
	print(sum(c))


class Swap:

	def __init__(self, N, K, arr1, arr2):
		self.n = N
		self.k = K
		self.arr1 = arr1
		self.arr2 = arr2

	def swap_array(self):
		self.arr1.sort()
		self.arr2.sort()
		idx = 0
		while idx < self.n and self.k > 0:
			if self.arr1[idx] < self.arr2[N - 1 - idx]:
				temp = self.arr1[idx]
				self.arr1[idx] = self.arr2[N - 1 - idx]
				self.arr2[N - 1 - idx] = temp
			idx += 1
			self.k -= 1
		return sum(self.arr1)
T = int(input())
for i in range(T):
	numbers = list(map(int, input().split()))
	(N, K) = (numbers[0], numbers[1])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	obj = Swap(N, K, a, b)
	print(obj.swap_array())


test = int(input())
for i in range(0, test):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	while k > 0:
		t = max(l2)
		v = min(l1)
		if v > t:
			break
		else:
			l2.remove(t)
			l2.append(v)
			l1.remove(v)
			l1.append(t)
		k = k - 1
	ans = sum(l1)
	print(ans)


test_cases = int(input())
for i in range(test_cases):
	first_line = input()
	n = int(first_line.split(' ')[0])
	k = int(first_line.split(' ')[1])
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	b.sort()
	for x in range(k):
		a.append(b[n - 1 - x])
	a.sort()
	res_sum = 0
	y = 0
	while y < len(a):
		if y > k - 1:
			res_sum = res_sum + a[y]
		y = y + 1
	print(res_sum)


def test_case(n, k):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(0, n):
		if k == 0:
			break
		if b[i] > a[i]:
			(a[i], b[i]) = (b[i], a[i])
			k -= 1
	return sum(a)
t = int(input())
result = []
for i in range(0, t):
	(n, k) = map(int, input().split())
	result.append(test_case(n, k))
for r in result:
	print(r)


test = int(input())
for t in range(test):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	su = 0
	for i in range(k):
		su += max(a[i], b[i])
	for i in range(k, n):
		su += a[i]
	print(su)


from sys import stdin, stdout
from bisect import bisect_left

def find(N, K2, A, B):
	A.sort(reverse=True)
	B.sort(reverse=True)
	A1 = [0]
	for i in A:
		A1.append(A1[-1] + i)
	B1 = [0]
	for i in B:
		B1.append(B1[-1] + i)
	B1.reverse()
	K = []
	for i in range(N + 1):
		K.append(A1[i] + B1[i])
	return max(K[-K2 - 1:])

def main():
	for _ in range(int(stdin.readline())):
		(N, K) = list(map(int, stdin.readline().split()))
		A = list(map(int, stdin.readline().split()))
		B = list(map(int, stdin.readline().split()))
		print(find(N, K, A, B))
main()


T = int(input())
for i in range(T):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	sumA = sum(a)
	if k == 0:
		print(sumA)
	else:
		index = 0
		difference = 0
		while a[index] < b[n - 1 - index]:
			difference += b[n - 1 - index] - a[index]
			index += 1
			if index == k:
				break
		print(sumA + difference)


t = int(input())
ans = []
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	suma = 0
	sumb = 0
	ind = 0
	if k > 0:
		mx = max([sum(b[:ind + 1]) - sum(a[:ind + 1]) for ind in range(k)])
	else:
		mx = 0
	if mx < 0:
		mx = 0
	ans.append(mx + sum(a))
for i in range(t):
	print(ans[i])


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ini = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	ini.sort()
	arr.sort(reverse=True)
	for j in range(k):
		if ini[j] < arr[j]:
			ini[j] = arr[j]
	print(sum(ini))


t = int(input())
for o in range(t):
	ar1 = list(map(int, input().split()))
	(n, k) = (ar1[0], ar1[1])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	ar1 = list(map(int, input().split()))
	ar2 = list(map(int, input().split()))
	ar1.sort()
	ar2.sort(reverse=True)
	for i in range(n):
		mi = -1
		mx = -1
		for j in range(n):
			if ar1[i] < ar2[j]:
				if ar2[j] > mx:
					mx = ar2[j]
					mi = j
		if mi != -1:
			if k > 0:
				(ar1[i], ar2[mi]) = (ar2[mi], ar1[i])
				k -= 1
			else:
				break
	print(sum(ar1))
	t -= 1


t = int(input())
for i in range(0, t):
	arr = input()
	l = list(map(int, arr.split(' ')))
	n = l[0]
	k = l[1]
	arr = input()
	ais = list(map(int, arr.split(' ')))
	arr = input()
	bis = list(map(int, arr.split(' ')))
	for i in range(0, k):
		ais.sort()
		ais.reverse()
		bis.sort()
		if min(ais) <= max(bis):
			to_b = ais.pop()
			to_a = bis.pop()
			ais.append(to_a)
			bis.append(to_b)
	print(sum(ais))


for _ in range(int(input())):
	nk = list(map(int, input().rstrip().split()))[:2]
	(n, k) = (nk[0], nk[1])
	a = list(map(int, input().rstrip().split()))[:n]
	b = list(map(int, input().rstrip().split()))[:n]
	for i in range(k):
		if min(a) < max(b):
			i1 = a.index(min(a))
			i2 = b.index(max(b))
			(a[i1], b[i2]) = (b[i2], a[i1])
	print(sum(a))


cases = int(input())
sums = []
for i in range(cases):
	(n, k) = input().split()
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	b.sort()
	a += b[int(n) - int(k):]
	a.sort()
	sums.append(sum(a[int(k):]))
for i in sums:
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[n - i - 1]:
			a[i] = b[n - i - 1]
	temp = 0
	for item in a:
		temp += item
	print(temp)


t = int(input())
for ii in range(t):
	astr = input()
	alst = astr.split()
	n = int(alst[0])
	k = int(alst[1])
	a = list()
	b = list()
	max = list()
	raw_a = input()
	raw_b = input()
	raw_alst = raw_a.split()
	raw_blst = raw_b.split()
	for pp in range(n):
		a.append(int(raw_alst[pp]))
		b.append(int(raw_blst[pp]))
	a.sort(reverse=True)
	b.sort(reverse=True)
	howmany = 0
	for m in range(k):
		if b[m] > a[n - 1 - m]:
			howmany = howmany + 1
		else:
			break
	for i in range(howmany):
		max.append(b[i])
	for iii in range(n - howmany):
		max.append(a[iii])
	print(sum(max))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	while k > 0 and len(b) > 0:
		if b[-1] < a[0]:
			break
		else:
			a[0] = b[-1]
			a = sorted(a)
			del b[-1]
		k -= 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	s = sum(a)
	if b[-1] <= a[0] or k == 0:
		print(s)
	else:
		candidates = b[-k:][::-1]
		l = len(candidates)
		i = j = 0
		while True:
			if i == n or j == l:
				break
			if a[i] < candidates[j]:
				s += candidates[j] - a[i]
				i += 1
				j += 1
			else:
				break
		print(s)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if a[0] < b[-1]:
			x = a.pop(0)
			y = b.pop(-1)
			a.append(y)
			b.insert(0, x)
		else:
			break
	print(sum(a))


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	mina = min(a)
	maxb = max(b)
	if mina >= maxb:
		print(sum(a))
	else:
		for i in range(k):
			mina = min(a)
			maxb = max(b)
			if mina >= maxb:
				break
			else:
				a.append(maxb)
				a.remove(mina)
				b.append(mina)
				b.remove(maxb)
		print(sum(a))


t = int(input())
for i in range(0, t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	a = input().split()
	b = input().split()
	for i in range(0, n):
		a[i] = int(a[i])
		b[i] = int(b[i])
	while k:
		if min(a) > max(b):
			break
		q = a.index(min(a))
		w = b.index(max(b))
		(a[q], b[w]) = (b[w], a[q])
		k -= 1
	print(sum(a))


def main():
	t = int(input())
	for __ in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a.sort()
		b.sort(reverse=True)
		i = 0
		j = 0
		while i < n and j < n and (k > 0):
			if a[i] < b[j]:
				(a[i], b[j]) = (b[j], a[i])
				j += 1
				k -= 1
			i += 1
		print(sum(a))
main()


t = int(input())
n_list = []
k_list = []
a_list = []
b_list = []
for i in range(t):
	(t1, t2) = input().split()
	n_list.append(int(t1))
	k_list.append(int(t2))
	a_list.append([int(x) for x in input().split()])
	b_list.append([int(x) for x in input().split()])
for i in range(t):
	a_list[i].sort()
	b_list[i].sort(reverse=True)
	for j in range(k_list[i]):
		if a_list[i][0] < b_list[i][0]:
			b_list[i].append(a_list[i][0])
			a_list[i].append(b_list[i][0])
			a_list[i].remove(a_list[i][0])
			b_list[i].remove(b_list[i][0])
			a_list[i].sort()
			b_list[i].sort(reverse=True)
	print(sum(a_list[i]))


t = int(input())
ans = []
for s in range(t):
	(n, k) = [int(x) for x in input().split()]
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l1.sort()
	l2.sort()
	l2.reverse()
	if l1[0] >= l2[0]:
		ans.append(sum(l1))
	else:
		i = 0
		while k >= 1 and i <= n - 1:
			if l1[i] < l2[i]:
				l1[i] = l2[i]
				k -= 1
				i += 1
			else:
				break
		ans.append(sum(l1))
for it in ans:
	print(it)


import sys
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	(n, k) = map(int, I().split())
	a = list(map(int, I().split()))
	b = list(map(int, I().split()))
	a.sort()
	b.sort(reverse=True)
	i = 0
	while k > 0 and i < n:
		if a[i] < b[i]:
			a[i] = b[i]
			i += 1
			k -= 1
		else:
			break
	ans += str(sum(a)) + '\n'
print(ans)


t = int(input())

def kl(a, b, k, n):
	s = 0
	for i in range(k):
		s += max(a[i], b[i])
	for i in range(k, n):
		s += a[i]
	return s
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	print(kl(a, b, k, n))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar.sort()
	br = list(map(int, input().split()))
	br.sort(reverse=True)
	for i in range(k):
		if ar[i] < br[i]:
			x = br[i]
			br[i] = ar[i]
			ar[i] = x
	print(sum(ar))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	x = sum(a)
	for j in range(k):
		if b[-1] > a[0]:
			x += b[-1] - a[0]
			a.remove(a[0])
			b.pop()
		else:
			break
	print(x)


def solve(array1, array2, moves):
	max_sum = 0
	for e in range(moves):
		if max(array2) > min(array1):
			array1[array1.index(min(array1))] = array2[array2.index(max(array2))]
			array2[array2.index(max(array2))] = array1[array1.index(min(array1))]
	max_sum += sum(array1)
	return max_sum
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(a, b, k))


t = int(input())
for T in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	a.sort()
	b.sort()
	(i, j) = (0, n - 1)
	while i < n and j >= 0 and (k > 0):
		if a[i] > b[j]:
			break
		else:
			i += 1
			j -= 1
		k -= 1
	s = 0
	s = sum(a[i:]) + sum(b[j + 1:])
	print(s)


T = int(input())
for t in range(T):
	tmp = input().split()
	(n, k) = (int(tmp[0]), int(tmp[1]))
	a = [0 for _ in range(n)]
	b = [0 for _ in range(n)]
	tmp = input().split()
	for i in range(n):
		a[i] = int(tmp[i])
	tmp = input().split()
	for i in range(n):
		b[i] = int(tmp[i])
	a.sort()
	b.sort()
	tot = 0
	for aa in a:
		tot += aa
	last = n - 1
	swap = min(k, n)
	for i in range(swap):
		if a[i] < b[last]:
			tot -= a[i]
			tot += b[last]
			last -= 1
		else:
			break
	print(tot)


num = int(input())
l = list()
for i in range(num):
	(len, swaps) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a = sorted(a)
	b = sorted(b, reverse=True)
	for j in range(swaps):
		if a[j] < b[j]:
			a[j] = b[j]
		else:
			break
	l.append(sum(a))
for i in l:
	print(i)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort(key=lambda x: -x)
	for i in range(min(k, len(b), len(a))):
		if a[i] > b[i]:
			break
		a[i] = b[i]
	print(sum(a))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, functools

def solve(line):
	(n, k) = map(int, line.split())
	a = sorted([int(x) for x in sys.stdin.readline().rstrip().split()])
	b = sorted([int(x) for x in sys.stdin.readline().rstrip().split()])
	(i, j) = (0, n - 1)
	ans = 0
	while k > 0 and i < n and (j >= 0):
		if a[i] < b[j]:
			ans += b[j]
			i += 1
			j -= 1
		else:
			ans += a[i]
			i += 1
		k -= 1
	while i < n:
		ans += a[i]
		i += 1
	return ans
T = int(sys.stdin.readline())
t = 0
while True:
	line = sys.stdin.readline().rstrip()
	if not line:
		break
	print(solve(line))
	t += 1


t = int(input())
(nLst, kLst) = ([], [])
(aArr, bArr) = ([], [])
for i in range(t):
	(ni, ki) = input().split(' ')
	(ni, ki) = (int(ni), int(ki))
	nLst.append(ni)
	kLst.append(ki)
	aArr_i = []
	aArr_i = input().split()
	for x in range(len(aArr_i)):
		aArr_i[x] = int(aArr_i[x])
	aArr.append(aArr_i)
	bArr_i = []
	bArr_i = input().split()
	for y in range(len(bArr_i)):
		bArr_i[y] = int(bArr_i[y])
	bArr.append(bArr_i)
for i in range(t):
	if kLst[i] > 0:
		for j in range(kLst[i]):
			if max(bArr[i]) > min(aArr[i]):
				aMin = min(aArr[i])
				bMax = max(bArr[i])
				aMin_i = aArr[i].index(aMin)
				bMax_i = bArr[i].index(bMax)
				aArr[i][aMin_i] = bMax
				bArr[i][bMax_i] = aMin
	else:
		print(sum(aArr[i]))
		continue
	print(sum(aArr[i]))


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())
entries = inp()
for i in range(entries):
	l = inlt()
	n = l[0]
	move = l[1]
	a = inlt()
	b = inlt()
	a.sort()
	b.sort()
	b_counter = n - 1
	for i in range(move):
		if a[i] < b[b_counter]:
			a[i] = b[b_counter]
			b_counter -= 1
		else:
			break
	res = sum(a)
	print(res)


nu = int(input())
for i in range(0, nu):
	(n, k) = input().split()
	a = input().split()
	b = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, a))
	b = list(map(int, b))
	for i in range(0, k):
		a.sort()
		b.sort()
		if a[0] < b[n - 1]:
			d = a[0]
			a[0] = b[n - 1]
			b[n - 1] = d
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	for j in range(k):
		if a[j] < b[n - j - 1]:
			a[j] = b[n - j - 1]
		else:
			break
	print(sum(a))


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

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n
for _ in range(int(input())):
	(n, k) = mi()
	a = li()
	b = li()
	b.sort(reverse=True)
	a.sort()
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k1) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	j = 0
	k = n - 1
	while k1 > 0 and j < n and (k >= 0):
		if l1[j] < l2[k]:
			(l1[j], l2[k]) = (l2[k], l1[j])
			k1 = k1 - 1
		j = j + 1
		k = k - 1
	print(sum(l1))


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	cur = 0
	while cur < k and cur < n and (b[n - cur - 1] > a[cur]):
		a[cur] = b[n - cur - 1]
		cur += 1
	print(sum(a))


from sys import stdout, stdin
(_input, _print) = (stdin.buffer.readline, stdout.write)
(_int, _sum, _range) = (int, sum, range)

def solution():
	for _ in _range(_int(_input())):
		(n, k) = [_int(i) for i in _input().split()]
		a = [_int(i) for i in _input().split()]
		b = [_int(i) for i in _input().split()]
		a.sort(reverse=False)
		b.sort(reverse=True)
		summary = 0
		current = 0
		for i in _range(n):
			if k > 0:
				if a[i] < b[current]:
					a[i] = b[current]
					current += 1
				k -= 1
			summary += a[i]
		print(summary)
solution()


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for _ in range(t):
	(n, k) = M()
	a = L()
	b = L()
	l = []
	for i in range(n):
		l.append([a[i], 0])
	for j in range(n):
		l.append([b[j], 1])
	a.sort()
	b.sort(reverse=True)
	l = a[:k] + b[:k]
	l.sort(reverse=True)
	s = sum(l[:k])
	a.sort(reverse=True)
	for i in range(n - k):
		s += a[i]
	print(s)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b = b[::-1]
	z = a + b
	z.sort()
	z = z[::-1]
	sum = 0
	elements = 0
	y = 0
	for j in range(2 * n):
		if elements < n:
			if z[j] in a:
				sum = sum + z[j]
				x = a.index(z[j])
				a[x] = -1
				elements = elements + 1
			elif y < k and k > 0:
				sum = sum + z[j]
				x = b.index(z[j])
				b[x] = -1
				y = y + 1
				elements = elements + 1
		else:
			break
	print(sum)


for i in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [i for i in sorted([int(i) for i in input().split()])]
	b = [i for i in sorted([int(i) for i in input().split()])]
	if b[-1] < a[0]:
		print(sum(a))
		continue
	else:
		p1 = -1
		p0 = 0
		asum = sum(a)
		s = 0
		while p0 < n and a[p0] < b[p1] and (s < k):
			asum -= a[p0]
			asum += b[p1]
			p0 += 1
			p1 -= 1
			s += 1
		print(asum)


import sys
input = sys.stdin.readline
rInt = lambda : int(input())
mInt = lambda : list(map(int, input().split()))
rLis = lambda : list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(n, k) = mInt()
	a = rLis()
	b = rLis()
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))


from sys import stdin, stdout
import math
n = int(stdin.readline())
for i in range(n):
	arr = [int(x) for x in stdin.readline().split()]
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	a.sort()
	b.sort(reverse=True)
	j = 0
	count = 0
	for i in range(arr[0]):
		if a[i] < b[j] and count < arr[1]:
			a[i] = b[j]
			j += 1
			count += 1
	ans = sum(a)
	stdout.write(str(ans) + '\n')


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
BUFSIZE = 8192
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 main():
	t = int(input())
	for i in range(t):
		nk = list(map(int, input().split()))
		(n, k) = (nk[0], nk[1])
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		sa = sorted(a)
		sb = sorted(b, reverse=True)
		if k == 0:
			print(sum(a))
			continue
		if sb[0] <= sa[0]:
			print(sum(a))
			continue
		index = 0
		while k > 0:
			if sa[index] >= sb[index]:
				break
			sa[index] = sb[index]
			k = k - 1
			index = index + 1
		print(sum(sa))
main()


n = int(input())
for i in range(n):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	b = sorted(b)
	c = sorted(c, reverse=True)
	for i in range(a[1]):
		if b[i] < c[i]:
			b.pop(i)
			b.insert(0, c[i])
	print(sum(b))


tc = int(input())
for _ in range(tc):
	var = 0
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if a[var] < b[n - i - 1]:
			tmp = a[var]
			a[var] = b[n - i - 1]
			b[n - i - 1] = tmp
			var += 1
	print(sum(a))


I = lambda : map(int, input().split())
for i in [0] * int(input()):
	(n, k) = I()
	a = sorted(I())
	b = sorted(I())
	b = b[::-1]
	for j in range(k):
		if b[j] > a[j]:
			a[j] = b[j]
	print(sum(a))


for i in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = len(b) - 1
	ans = 0
	while i < len(a):
		if k and j >= 0:
			if b[j] > a[i]:
				ans += b[j]
				j -= 1
				i += 1
				k -= 1
			else:
				ans += a[i]
				i += 1
				j -= 1
		else:
			ans += a[i]
			i += 1
	print(ans)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(m):
		if min(a) < max(b):
			first = a.index(min(a))
			l = a[first]
			second = b.index(max(b))
			lo = b[second]
			a[first] = lo
			b[second] = l
	print(sum(a))


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort()
	i = 0
	while i < min(k, n):
		if arr1[i] < arr2[n - i - 1]:
			(arr1[i], arr2[n - i - 1]) = (arr2[n - i - 1], arr1[i])
			i += 1
		else:
			break
	res = 0
	for c in arr1:
		res += c
	print(res)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(a)
	na = []
	for i in range(k):
		m = max(b)
		n = min(a)
		im = b.index(m)
		imn = a.index(n)
		a[imn] = b[im]
		b[im] = n
		ns = sum(a)
		s = max(s, ns)
	print(s)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	s = sum(A)
	if k != 0:
		for i in range(1, k + 1):
			ar = A[i:] + B[-i:]
			s = max(s, sum(ar))
	if k == 0:
		s = sum(A)
	print(s)


def swap_sum(a, b, cnt, k):
	if cnt == k or min(a) >= max(b):
		return sum(a)
	else:
		i = a.index(min(a))
		j = b.index(max(b))
		(a[i], b[j]) = (b[j], a[i])
		return swap_sum(a, b, cnt + 1, k)
for ii in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(swap_sum(a, b, 0, k))


case = int(input())
for i in range(case):
	nums = [int(j) for j in input().split()]
	a = [int(k) for k in input().split()]
	b = [int(l) for l in input().split()]
	for m in range(nums[1]):
		if min(a) < max(b):
			ai = a.index(min(a))
			bi = b.index(max(b))
			temp = a[ai]
			a[ai] = b[bi]
			b[bi] = temp
		else:
			break
	print(sum(a))


def count():
	(n, k) = list(map(int, input().split()))
	(a, b) = (list(map(int, input().split())), list(map(int, input().split())))
	for i in range(k):
		if max(b) > min(a):
			a[a.index(min(a))] = max(b)
			b.remove(max(b))
	return sum(a)
for i in range(int(input())):
	print(count())


def maxSum(n, k, a, b):
	a.sort()
	b.sort()
	x = 0
	y = n - 1
	for i in range(k):
		if b[y] > a[x]:
			(b[y], a[x]) = (a[x], b[y])
			x += 1
			y -= 1
		else:
			break
	print(sum(a))

def main():
	t = int(input())
	for i in range(t):
		(n, m) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		maxSum(n, m, a, b)
main()


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k != 0:
		m1 = min(a)
		m2 = max(b)
		if m1 < m2:
			a.remove(m1)
			b.remove(m2)
			a.append(m2)
			b.append(m1)
		k -= 1
	print(sum(a))
	t -= 1


for _ in range(int(input())):
	(m, k) = map(int, input().split())
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()])
	for i in range(k):
		a = sorted(a)
		b = sorted(b)
		if b[-1] > a[0]:
			a[0] = b[-1]
			b = b[:-1]
	print(sum(a))


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	suma = 0
	for i in range(n):
		if k == 0:
			suma += a[i]
		else:
			suma += max(a[i], b[i])
			k -= 1
	print(suma)


S = lambda : sorted(map(int, input().split()))
for _ in range(int(input())):
	(k, n) = S()
	(A, B) = (S(), S())
	for i in range(k):
		A[i] = max(A[i], B[-i - 1])
	print(sum(A))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort()
	a.sort()
	y = sum(a)
	for i in range(k):
		for x in range(len(b) - 1, len(b) - 2, -1):
			if a[i] < b[-1]:
				y -= a[i] - b[x]
				b.remove(b[x])
	print(y)


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	j = 0
	while j != k:
		if a[0] < b[n - 1]:
			a.append(b[n - 1])
			b.append(a[0])
			del b[n - 1]
			del a[0]
			a.sort()
			b.sort()
		j = j + 1
	ans = sum(a)
	print(ans)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	arra = list(map(int, input().split()))
	arrb = list(map(int, input().split()))
	suma = 0
	for i in range(len(arra)):
		suma += arra[i]
	arra.sort()
	arrb.sort()
	for i in range(k):
		try:
			if arrb[n - 1] > arra[0]:
				suma -= arra[0]
				suma += arrb[n - 1]
				arra = arra[1:]
				arrb = arrb[:n - 1]
				n = n - 1
			else:
				break
		except:
			break
	print(suma)


def solve(n, k, arr1, arr2):
	arr1.sort()
	arr2.sort(reverse=True)
	total = 0
	for i in range(0, n):
		if i < k:
			total = total + max(arr1[i], arr2[i])
		else:
			total = total + arr1[i]
	print(total)
test_case = int(input())
while test_case != 0:
	(n, k) = map(int, input().split(' '))
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	solve(n, k, arr1, arr2)
	test_case = test_case - 1


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

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

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

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		(n, k) = In()
		arr1 = L()
		arr1.sort()
		arr2 = L()
		arr2.sort()
		sm = sum(arr1)
		for i in range(k):
			if arr1[i] < arr2[n - 1 - i]:
				sm += arr2[n - 1 - i] - arr1[i]
			else:
				break
		print(sm)
main()


t = int(input())
for _ in range(t):
	nk = list(map(int, input().split()))
	(n, k) = (nk[0], nk[1])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	(i, j) = (0, 0)
	flag = 0
	while i < n and j < n and (flag < k):
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			i += 1
			j += 1
			flag += 1
		else:
			break
	print(sum(a))


import sys, math, cmath, time
start_time = time.time()
tt = 0

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

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

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

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

def solve():
	(n, k) = invr()
	a = inlt()
	b = inlt()
	a.sort()
	b.sort()
	c = 0
	if k == 0:
		print(sum(a))
		return
	for i in range(len(a)):
		if a[i] < b[-1]:
			a[i] = b.pop()
			c = c + 1
		if c >= k:
			break
	print(sum(a))

def main():
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
	sys.stdout.close()

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


t = int(input())
ans = ''
for i in range(t):
	inp = input().split()
	n = int(inp[0])
	k = int(inp[1])
	a = input().split()
	b = input().split()
	a = sorted([int(j) for j in a])
	b = sorted([int(j) for j in b])
	x = 0
	while x < k:
		if int(a[x]) < int(b[n - 1 - x]):
			a[x] = b[n - 1 - x]
			x += 1
		else:
			break
	r = 0
	for z in range(n):
		r += a[z]
	ans += str(r) + '\n'
print(ans)


t = int(input())
for ts in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	suma = sum(a)
	for i in range(k):
		if min(a) < max(b):
			suma = suma - min(a) + max(b)
			a.remove(min(a))
			b.remove(max(b))
		else:
			break
	print(suma)


import sys

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(n, k) = mints()
	a = list(mints())
	b = list(mints())
	for i in range(k):
		m = a.index(min(a))
		M = b.index(max(b))
		if a[m] < b[M]:
			(a[m], b[M]) = (b[M], a[m])
	print(sum(a))
for i in range(mint()):
	solve()


numberofquestion = int(input())
for i in range(numberofquestion):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for p in range(k):
		mmin = min(a)
		mmax = max(b)
		if mmin < mmax:
			a[a.index(mmin)] = mmax
			b.remove(mmax)
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	for i in range(k):
		x = l1.index(min(l1))
		y = l2.index(max(l2))
		if l1[x] < l2[y]:
			temp = l1[x]
			l1[x] = l2[y]
			l2[y] = temp
		else:
			break
	print(sum(l1))


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	la = [int(x) for x in input().split()]
	lb = [int(x) for x in input().split()]
	for x in range(k):
		mina = min(la)
		if min(la) < max(lb):
			la[la.index(min(la))] = max(lb)
			lb[lb.index(max(lb))] = mina
	print(sum(la))


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()], reverse=True)
	result = 0
	for i in range(n):
		result += max(a[i], b[i]) if i < k else a[i]
	print(result)


inp = lambda : map(int, input().split())
t = int(input())
for _ in range(t):
	(n, k) = inp()
	a = list(inp())
	b = list(inp())
	sa = sorted(a)
	sb = sorted(b)
	sb = sb[::-1]
	for i in range(k):
		if sa[i] < sb[i]:
			(sa[i], sb[i]) = (sb[i], sa[i])
		else:
			pass
	print(sum(sa))


def swap(a, b):
	return (b, a)
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(n):
		if k > 0 and a[i] <= b[i]:
			k -= 1
			(a[i], b[i]) = swap(a[i], b[i])
	print(sum(a))


m = int(input())
for j in range(m):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	kmina = a[:k]
	kmaxb = b[:k]
	kmina.sort()
	kmaxb.sort()
	kmaxb.reverse()
	if k > 0:
		for i in range(k, n):
			if a[i] < kmina[-1]:
				kmina.pop()
				kmina.append(a[i])
				pos = k - 1
				while pos != 0 and kmina[pos] < kmina[pos - 1]:
					(kmina[pos], kmina[pos - 1]) = (kmina[pos - 1], kmina[pos])
					pos -= 1
			if b[i] > kmaxb[-1]:
				kmaxb.pop()
				kmaxb.append(b[i])
				pos = k - 1
				while pos != 0 and kmaxb[pos] > kmaxb[pos - 1]:
					(kmaxb[pos], kmaxb[pos - 1]) = (kmaxb[pos - 1], kmaxb[pos])
					pos -= 1
		i = 0
		sum_ = 0
		while i < k and kmina[i] < kmaxb[i]:
			sum_ += kmaxb[i] - kmina[i]
			i += 1
		print(sum(a) + sum_)
	else:
		print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k > 0:
		if min(a) < max(b):
			a.remove(min(a))
			a.append(max(b))
			b.remove(max(b))
		k = k - 1
	print(sum(a))


t = int(input())
for test in range(t):
	nk = input()
	nk = nk.strip()
	nk = nk.split(' ')
	nk = list(map(int, nk))
	n = nk[0]
	k = nk[1]
	a = input()
	a = a.strip()
	a = a.split(' ')
	a = list(map(int, a))
	b = input()
	b = b.strip()
	b = b.split(' ')
	b = list(map(int, b))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_index = sorted(range(n), key=a.__getitem__)
	b_index = sorted(range(n), key=b.__getitem__, reverse=True)
	cnt = 0
	for i in range(n):
		if cnt == k:
			break
		if a[a_index[i]] < b[b_index[i]]:
			a[a_index[i]] = b[b_index[i]]
			cnt += 1
		else:
			break
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	z = [sum(a)]
	for i in range(k):
		x = a[i]
		y = b[i]
		if x < y:
			a[i] = y
		z.append(sum(a))
	print(max(z))


from sys import stdin, stdout, exit as sys_ret
(f_input, f_print, f_flush) = (stdin.readline, stdout.write, stdout.flush)
for _ in range(int(f_input())):
	(amount, steps) = map(int, f_input().split())
	first = sorted([int(i) for i in f_input().split()])
	second = sorted([int(i) for i in f_input().split()], reverse=True)
	i = 0
	while steps != 0 and i < amount:
		if first[i] < second[i]:
			steps -= 1
			(first[i], second[i]) = (second[i], first[i])
		i += 1
	f_print(str(sum(first)) + '\n')


tc = int(input())
while tc > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	a += b[:k]
	a.sort()
	print(sum(a[k:]))
	tc -= 1


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


t = int(input())
import heapq
for _ in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	B = [-b for b in B]
	heapq.heapify(A)
	heapq.heapify(B)
	for i in range(k):
		a = heapq.heappop(A)
		b = heapq.heappop(B) * -1
		(x, y) = (max(a, b), min(a, b))
		heapq.heappush(A, x)
		heapq.heappush(B, -y)
	A = list(A)
	print(sum(A))


t = int(input())
for q in range(t):
	(n, k) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort()
	b = list(reversed(b))
	cont = 0
	indice = 0
	for i in range(n):
		if b[i] > a[i] and k > 0:
			cont += b[i]
			indice += 1
			k -= 1
		else:
			break
	for j in range(indice, n):
		cont += a[j]
	print(cont)


import math
import sys
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	while k > 0 and j >= 0 and (i < n) and (a[i] < b[j]):
		(a[i], b[j]) = (b[j], a[i])
		k -= 1
		i += 1
		j -= 1
	print(sum(a))


import sys
import math

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]
t = int(input())
for q in range(t):
	(n, k) = inputnums()
	a = inputlist()
	b = inputlist()
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	ans = 0
	for i in range(n):
		ans += a[i]
	print(ans)


T = int(input())
for z in range(T):
	(N, K) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	i = 0
	j = N - 1
	while i != K and i < N and (j >= 0):
		if b[j] > a[i]:
			(a[i], b[j]) = (b[j], a[i])
			i += 1
			j -= 1
		else:
			i += 1
			j -= 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	i = 0
	while k > 0 and i < n:
		if a[i] >= b[n - 1 - i]:
			break
		(a[i], b[n - 1 - i]) = (b[n - 1 - i], a[i])
		i = i + 1
		k = k - 1
	res = 0
	for i in a:
		res = res + i
	print(res)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	cnt = 0
	for i in range(n):
		if i < k:
			cnt += max(a[i], b[i])
		else:
			cnt += a[i]
	print(cnt)


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [i for i in input().split()]
t = int(input())
while t:
	t -= 1
	(n, k) = value()
	a = arr()
	b = arr()
	b.sort(reverse=True)
	a.sort()
	for i in range(n):
		if a[i] < b[i] and k > 0:
			a[i] = b[i]
			k -= 1
		else:
			break
	print(sum(a))


numTests = int(input())
for i in range(numTests):
	(n, k) = list((int(i) for i in input().split(' ')))
	a = list((int(i) for i in input().split(' ')))
	b = list((int(i) for i in input().split(' ')))
	a.sort()
	b.sort()
	b_index = len(b) - 1
	if k > 0:
		for i in range(len(a)):
			if a[i] < b[b_index]:
				a[i] = b[b_index]
				b_index -= 1
				k -= 1
				if k == 0:
					break
	print(sum(a))


t = int(input())
out = []
for i in range(t):
	(n, k) = input().split()
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	for i in range(int(k)):
		min_a = min(a)
		max_b = max(b)
		if min_a < max_b:
			temp = a[a.index(min_a)]
			a[a.index(min_a)] = b[b.index(max_b)]
			b[b.index(max_b)] = temp
	out.append(sum(a))
for i in range(t):
	print(out[i])


t = int(input())
for _ in range(t):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = min(a)
	y = max(b)
	while x < y and k > 0:
		a[a.index(x)] = y
		b[b.index(y)] = x
		x = min(a)
		y = max(b)
		k -= 1
	print(sum(a))


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

def solve():
	(size, k) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort()
	while k > 0:
		tmp = b.pop(len(b) - 1)
		if tmp <= a[0]:
			break
		a.append(tmp)
		a.pop(0)
		k -= 1
	print(sum(a))
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	a = sorted(list(map(int, input().split(' ')[:n])))
	b = sorted(list(map(int, input().split(' ')[:n])))
	while k != 0:
		mi = min(a)
		i1 = a.index(mi)
		ma = max(b)
		i2 = b.index(ma)
		a[i1] = max(mi, ma)
		b[i2] = min(mi, ma)
		k -= 1
	print(sum(a))


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	a.sort()
	b.sort(key=lambda x: -x)
	ans = sum(a)
	for i in range(n):
		if k <= 0:
			break
		if a[i] < b[i]:
			ans += b[i] - a[i]
			k -= 1
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	a1 = input().split()
	b1 = input().split()
	for k in range(a):
		a1[k] = int(a1[k])
		b1[k] = int(b1[k])
	b1.sort()
	for j in range(b):
		a1.append(b1[a - 1 - j])
	a1.sort()
	sum = 0
	for j in range(b, len(a1)):
		sum += a1[j]
	print(sum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for _ in range(k):
		a.append(max(b))
		b.append(min(a))
		a.remove(min(a))
		b.remove(max(b))
	print(sum(a))


tests = int(input())
for i in range(0, tests):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b = b[::-1]
	first = 0
	if k > 0:
		while first < k:
			if a[first] < b[first]:
				a[first] = b[first]
				first += 1
			else:
				break
		print(sum(a))
	else:
		print(sum(a))


for _ in range(int(input())):
	(n, k) = input().split()
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	(c, x) = (0, 0)
	for i in range(len(a)):
		if i <= int(k) - 1 and b[i] > a[i]:
			x = x + 1
			c = c + int(b[i])
		if i > x - 1:
			c = c + int(a[i])
	print(c)


import sys
cases = int(sys.stdin.readline())
for _ in range(cases):
	(n, k) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	ans = sum(sorted(sorted(a) + sorted(b)[n - k:])[k:])
	print(ans)


t = int(input())
final = []

def sum(arr):
	sum = 0
	for i in arr:
		sum += i
	return sum
for z in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	if a[0] >= b[0] or k == 0:
		final.append(sum(a))
	else:
		for j in range(k):
			if j < n:
				if a[j] < b[j]:
					a[j] = b[j]
		final.append(sum(a))
for z in range(t):
	print(final[z])


t = int(input())
for _ in range(t):
	(n, k) = tuple(map(int, input().split(' ')))
	alis = list(map(int, input().split(' ')))
	blis = list(map(int, input().split(' ')))
	alis.sort()
	blis.sort(reverse=True)
	sum = 0
	for i in range(k):
		if alis[i] < blis[i]:
			sum += blis[i]
		else:
			sum += alis[i]
	for i in range(k, n):
		sum += alis[i]
	print(sum)


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

def read():
	t = int(input())
	data = []
	for i in range(t):
		(n, k) = read_ints()
		a = read_ints()
		b = read_ints()
		data.append((a, b, k))
	return data

def solve(data):
	ret = []
	for (a, b, k) in data:
		a.sort()
		b.sort(reverse=True)
		for i in range(k):
			if a[i] >= b[i]:
				break
			else:
				a[i] = b[i]
		ret.append(sum(a))
	return ret

def print_out(ret):
	for x in ret:
		print(x)
data = read()
ret = solve(data)
print_out(ret)


def swap():
	for i in range(k):
		a.sort()
		b.sort()
		if a[0] < b[n - 1]:
			(a[0], b[n - 1]) = (b[n - 1], a[0])
	print(sum(a))

def con(arr):
	for i in range(n):
		arr[i] = int(arr[i])
t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(input().split())
	b = list(input().split())
	con(a)
	con(b)
	swap()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = sorted(list(map(int, input().split())))
	brr = list(map(int, input().split()))
	brr.sort(reverse=True)
	count = 0
	for j in range(k):
		if arr[j] < brr[j]:
			arr[j] = brr[j]
	print(sum(arr))


t = int(input())
for i in range(t):
	array1 = list(input().split(' '))
	n = int(array1[0])
	k = int(array1[1])
	a = list(input().split(' '))
	b = list(input().split(' '))
	(a1, b1) = ([], [])
	for i in range(len(a)):
		a1.append(int(a[i]))
	for i in range(len(b)):
		b1.append(int(b[i]))
	a1.sort()
	b1.sort()
	for i in range(0, k):
		if a1[0] < b1[n - i - 1]:
			del a1[0]
			a1.append(b1[n - i - 1])
	suma = 0
	for i in range(len(a)):
		suma = suma + a1[i]
	print(suma)


def swap(arr1, arr2, k):
	arr1.sort()
	arr2 = sorted(arr2, reverse=True)
	if k == 0:
		return sum(arr1)
	if arr1[0] >= arr2[0]:
		return sum(arr1)
	i = 0
	while i < k:
		if arr1[i] < arr2[i]:
			(arr1[i], arr2[i]) = (arr2[i], arr1[i])
		else:
			break
		i += 1
	return sum(arr1)
tc = int(input())
for test in range(tc):
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	print(swap(arr1, arr2, k))


i = int(input())
for x in range(i):
	(n, k) = input('').split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for z in range(0, k):
		if a[z] < b[n - 1 - z]:
			a[z] = b[n - 1 - z]
	print(sum(a))


T = int(input())
for _ in range(T):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)[::-1]
	(ans, j) = (0, 0)
	for i in range(n):
		if j < k and a[i] < b[j]:
			ans += b[j]
			j += 1
		else:
			ans += a[i]
	print(ans)


n = int(input())
for i in range(n):
	string = input()
	arrC = string.split()
	m = int(arrC[1])
	string1 = input()
	string2 = input()
	arrA = [int(x) for x in string1.split()]
	arrB = [int(y) for y in string2.split()]
	for i in range(m):
		minimum = min(arrA)
		maximum = max(arrB)
		if maximum < minimum:
			break
		indexB = arrB.index(maximum)
		temp = arrB.pop(indexB)
		arrB.append(minimum)
		arrA.remove(minimum)
		arrA.append(temp)
	print(sum(arrA))


t = int(input())
for i in range(t):
	x = input().split()
	n = int(x[0])
	k = int(x[1])
	a = []
	x = input().split()
	for i in x:
		a.append(int(i))
	a.sort()
	b = []
	x = input().split()
	for i in x:
		b.append(int(i))
	b.sort()
	x = 0
	if k != 0:
		if a[k - 1] <= b[-k]:
			a.extend(b[-k:])
		else:
			a.extend(b)
		a.sort()
		for i in range(n):
			x += a[-i - 1]
	else:
		for i in a:
			x += i
	print(x)


n = int(input())
for i in range(n):
	(n, k) = map(int, input().split())
	li1 = [int(i) for i in input().split()]
	li2 = [int(i) for i in input().split()]
	li1.sort()
	li2.sort(reverse=True)
	for x in range(k):
		if li1[x] < li2[x]:
			li1[x] = li2[x]
		else:
			pass
	final = 0
	for i in range(len(li1)):
		final += li1[i]
	print(final)


from math import *
from collections import *
from itertools import *
from bisect import *
from operator import *
import sys
sys.setrecursionlimit(1000000)

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

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

def o():
	return int(input())

def kl(con, x=0):
	if x == 0:
		print('Yes') if con else print('No')
	elif x == 1:
		print('yes') if con else print('no')
	elif x == 2:
		print('YES') if con else print('NO')
p = input
for _ in range(o()):
	(n, k) = io()
	(l1, l2) = (op(), op())
	l1.sort()
	l2.sort()
	c = len(l1) - 1
	for i in range(k):
		if l1[i] < l2[c]:
			l1[i] = l2[c]
			c -= 1
		else:
			break
	print(sum(l1))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()])
	kol = 0
	summ = 0
	for i in range(n):
		if kol < k:
			if a[i] <= b[n - 1 - i]:
				summ += b[n - 1 - i]
				kol += 1
			else:
				kol = k
				summ += a[i]
		else:
			summ += a[i]
	print(summ)


t = int(input())
for data in range(t):
	summa = 0
	nk = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(nk[1]):
		minimum = 31
		minimum_index = -1
		maximum = 0
		maximum_index = -1
		for j in range(nk[0]):
			if a[j] < minimum:
				minimum_index = j
				minimum = a[j]
			if b[j] > maximum:
				maximum_index = j
				maximum = b[j]
		if maximum > minimum:
			a[minimum_index] = b[maximum_index]
			b[maximum_index] = 0
	for l in range(nk[0]):
		summa += a[l]
	print(summa)


test_case = int(input())
for q in range(test_case):
	(n, k) = [int(_) for _ in input().split()]
	a = [int(a) for a in input().split()][:n]
	b = [int(b) for b in input().split()][:n]
	a.sort()
	b.sort()
	for i in range(k):
		if b[n - i - 1] > a[i]:
			a[i] = b[n - i - 1]
		else:
			break
	ans = 0
	for j in range(n):
		ans = ans + a[j]
	print(ans)


def dbg(*args):
	pass

def solve(a, b, k):
	dbg('-------- k: ', k)
	a.sort()
	b.sort(reverse=True)
	dbg('a: ', a)
	dbg('b: ', b)
	ans = 0
	for i in range(0, len(a)):
		if i + 1 <= k:
			ans += max(a[i], b[i])
		else:
			ans += a[i]
	return ans
ttt = int(input())
for tt in range(1, ttt + 1):
	(_, k) = [int(x) for x in input().strip().split(' ')]
	a = [int(x) for x in input().strip().split(' ')]
	b = [int(x) for x in input().strip().split(' ')]
	print(solve(a, b, k))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(y):
		c = a.index(min(a))
		d = b.index(max(b))
		if a[c] < b[d]:
			(a[c], b[d]) = (b[d], a[c])
		else:
			break
	print(sum(a))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	j = 0
	k1 = 0
	ans = sum(a)
	s = 0
	while s < k:
		if a[j] < b[k1]:
			ans += b[k1] - a[j]
			j += 1
			k1 += 1
			s += 1
		else:
			break
	print(ans)
	t -= 1


def get():
	(N, K) = map(int, input().split())
	P = sorted(list(map(int, input().split())))
	Q = sorted(list(map(int, input().split())))
	N -= 1
	for i in range(K):
		if P[i] < Q[N]:
			P[i] = Q[N]
			N -= 1
		else:
			break
	print(sum(P))
for _ in range(int(input())):
	get()


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.sort()
	b.sort()
	i = 0
	j = n - 1
	while m > 0 and i < n and (b[j] > a[i]):
		(b[j], a[i]) = (a[i], b[j])
		i += 1
		j -= 1
		m -= 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	count = 0
	while count < k:
		if a[i] < b[j]:
			temp = b[j]
			b[j] = a[i]
			a[i] = temp
			i += 1
			j -= 1
		else:
			break
		count += 1
	print(sum(a))


inp = input
li = list
iinp = lambda : int(inp())
ent = lambda : map(int, inp().split())
lient = lambda : [int(i) for i in inp().split()]
li0 = lambda x: [0 for i in range(x)]
livalor = lambda valor, x: [valor for i in range(x)]
stent = lambda : [i for i in inp()]
filldp = lambda valor, x, y: [[valor for i in range(y)] for i in range(x)]
ma = max
mi = min
s = sum
t = iinp()
for _ in range(t):
	(n, k) = ent()
	listaA = lient()
	listaB = lient()
	listaA.sort(reverse=True)
	listaB.sort()
	for i in range(k):
		if listaB[-1] <= listaA[-1]:
			break
		listaA.insert(0, listaB[-1])
		listaB.insert(0, listaA[-1])
		listaA.pop(-1)
		listaB.pop(-1)
	print(s(listaA))


from sys import stdin, stdout
for test in range(int(stdin.readline())):
	arr = [int(x) for x in stdin.readline().split()]
	n = arr[0]
	k = arr[1]
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	a.sort()
	b.sort()
	for i in range(k):
		if b[n - 1 - i] > a[i]:
			a[i] = b[n - 1 - i]
	stdout.write(str(sum(a)) + '\n')


I = input
for _ in range(int(I())):
	(n, k) = map(int, I().split())
	a = list(map(int, I().split()))
	b = list(map(int, I().split()))
	s = sum(a)
	for i in range(k):
		if max(b) > min(a):
			s -= min(a)
			s += max(b)
			a.remove(min(a))
			b.remove(max(b))
	print(s)


for _p in range(int(input())):
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	li2 = list(map(int, input().split()))
	while k:
		if min(li) >= max(li2):
			break
		else:
			a = min(li)
			b = max(li2)
			li.remove(a)
			li.append(b)
			li2.remove(b)
			li2.append(a)
		k -= 1
	print(sum(li))


import sys
import math

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

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

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, m) = get_ints()
	a = get_array()
	b = get_array()
	c = sorted(a)
	d = sorted(b)
	for i in range(m):
		if c[i] < d[n - i - 1]:
			temp = d[n - i - 1]
			d[n - i - 1] = c[i]
			c[i] = temp
	print(sum(c))


import sys
input = sys.stdin.buffer.readline
t = int(input())
ans = []
for _ in range(t):
	(n, k) = map(int, input().split())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	if n <= k:
		ans.append(sum(sorted(a + b)[n:]))
	else:
		su = sum(a)
		for (x, y) in zip(sorted(a)[:k], sorted(b, reverse=True)[:k]):
			if x < y:
				su -= x
				su += y
			else:
				break
		ans.append(su)
print('\n'.join(map(str, ans)))


tests = int(input())
while tests > 0:
	(arrayLength, allowedChanges) = [int(i) for i in input().split(' ')]
	aArray = sorted([int(i) for i in input().split(' ')])
	bArray = list(reversed(sorted([int(i) for i in input().split(' ')])))
	i = 0
	while i < allowedChanges:
		if aArray[i] < bArray[i]:
			aArray[i] = bArray[i]
		else:
			break
		i = i + 1
	print(sum(aArray))
	tests = tests - 1


n = int(input())
z = []
for i in range(n):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	e = b
	f = 0
	c.sort()
	d.sort()
	d.reverse()
	while b > 0:
		if c[e - b] < d[e - b]:
			c[e - b] = d[e - b]
		b = b - 1
	for i in range(len(c)):
		f = f + c[i]
	z.append(f)
for i in range(len(z)):
	print(z[i])


f = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, k) = f()
	i = 0
	a = sorted(list(f()))
	b = sorted(list(f()), reverse=True)
	while k > 0:
		if a[i] < b[i]:
			a[i] = b[i]
		k -= 1
		i += 1
	print(sum(a))


t = int(input())
for z in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		min = a[0]
		max = b[0]
		p = 0
		q = 0
		for j in range(n - 1):
			if a[j + 1] < min:
				min = a[j + 1]
				p = j + 1
		for k in range(n - 1):
			if b[k + 1] > max:
				max = b[k + 1]
				q = k + 1
		if max > min:
			a[p] = max
			b[q] = min
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()], reverse=True)
	s = 0
	for i in range(n):
		if a[i] < b[i] and k > 0:
			s += b[i]
			k -= 1
		else:
			s += a[i]
	print(s)


n = int(input())
for i in range(n):
	(x, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	c = b[::-1]
	l = []
	j = 0
	while j < k:
		if a[j] < c[j]:
			(a[j], c[j]) = (c[j], a[j])
		g = sum(a)
		l.append(g)
		j += 1
	if len(l) == 0:
		print(sum(a))
	else:
		print(max(l))


import math
import bisect
T = int(input())
for t in range(T):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort(reverse=True)
	B.sort(reverse=True)
	n = 1
	i = 0
	j = 0
	k = K
	out = 0
	while n <= N:
		if k > 0:
			if A[i] >= B[j]:
				out += A[i]
				i += 1
			else:
				out += B[j]
				j += 1
				k -= 1
		else:
			out += A[i]
			i += 1
		n += 1
	print(out)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	su = sum(a)
	(p1, p2) = (0, n - 1)
	while p1 < n and p2 >= 0 and (a[p1] <= b[p2]) and (k > 0):
		su = su + b[p2] - a[p1]
		k -= 1
		p2 -= 1
		p1 += 1
	print(su)
	t -= 1


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for j in range(k):
		a[j] = max(a[j], b[len(b) - j - 1])
	print(sum(a))


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	a.sort()
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
		else:
			break
	print(sum(a))


T = int(input())

def solve(array1, array2, k):
	array1 = sorted(array1)
	array2 = sorted(array2)
	for i in range(k):
		if array1[i] < array2[-1 - i]:
			(array1[i], array2[-1 - i]) = (array2[-1 - i], array1[i])
		else:
			break
	return sum(array1)
out_li = []
for _ in range(T):
	n_k = list(map(int, input().split()))
	array1 = list(map(int, input().split()))
	array2 = list(map(int, input().split()))
	out_li.append(solve(array1, array2, n_k[1]))
for num in out_li:
	print(num)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(str(i)[2:-1]) for i in input().rstrip()]
for _ in range(val()):
	(n, k) = li()
	a = sorted(li())
	b = sorted(li())
	for i in range(k):
		a[i] = max(a[i], b[n - i - 1])
	print(sum(a))


def ans(a, b, n, k):
	a.sort(reverse=True)
	b.sort()
	(f, g) = (n - 1, n - 1)
	i = 0
	while i < k and f >= 0 and (g >= 0):
		if b[g] > a[f]:
			temp = a[f]
			a[f] = b[g]
			b[g] = temp
			f -= 1
			g -= 1
			i += 1
		else:
			break
	return sum(a)
o = int(input())
for i in range(o):
	arr1 = input().split()
	n = int(arr1[0])
	k = int(arr1[1])
	arr2 = input().split()
	a = []
	for i in arr2:
		a.append(int(i))
	arr3 = input().split()
	b = []
	for i in arr3:
		b.append(int(i))
	print(ans(a, b, n, k))


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	A = [int(a) for a in input().split()]
	B = [int(b) for b in input().split()]
	if k == 0:
		print(sum(A))
	else:
		A.sort()
		B.sort(reverse=True)
		p = 0
		q = 0
		kt = 0
		maxi = -1000000
		while p < n and q < n and (kt < k):
			if A[p] < B[q]:
				temp = A[p]
				A[p] = B[q]
				B[q] = temp
				kt += 1
				p += 1
				q += 1
			else:
				q += 1
			if sum(A) > maxi:
				maxi = sum(A)
		print(maxi)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b = b[::-1]
	s = 0
	i = 0
	j = 0
	for _ in range(k):
		if a[i] >= b[i]:
			s += sum(a[i:])
			i = n
			break
		else:
			i += 1
			s += b[j]
			j += 1
	s += sum(a[i:])
	print(s)


t = int(input())
for w in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a = sorted(a)
	b = sorted(b)
	i = 0
	while b[n - 1] > a[0] and i < k:
		x = b[n - 1]
		y = a[0]
		a[0] = x
		b[n - 1] = y
		a = sorted(a)
		b = sorted(b)
		i += 1
	print(sum(a))


t = int(input())
for i in range(t):
	a = []
	a = list(map(int, input().split()))
	n = a[0]
	k = a[1]
	a = []
	a = list(map(int, input().split()))
	b = []
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	sum = 0
	for j in range(k):
		sum += max(a[j], b[n - j - 1])
	for j in range(n - k):
		sum += a[k + j]
	print(sum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = sum(a)
	a_index = 0
	b_index = n - 1
	for i in range(k):
		_b = b[b_index]
		_a = a[a_index]
		if _b > _a:
			ans += _b - _a
		else:
			break
		b_index -= 1
		a_index += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(x) for x in input().split()])
	b.reverse()
	for i in range(k):
		for j in range(n):
			if a[j] <= b[j]:
				a.append(b[j])
				a.remove(a[j])
				b.remove(b[j])
				b.append(a[j])
				break
			else:
				j += 1
				break
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))[::-1]
	b = sorted(map(int, input().split()))
	s = 0
	while k and a and (a[-1] < b[-1]):
		s += b.pop()
		a.pop()
		k -= 1
	print(s + sum(a))


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

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

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline().rstrip()
res = ['YES', 'NO']
test_case = ii()
while test_case:
	test_case -= 1
	(n, k) = mi()
	a = li()
	b = li()
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] >= b[i]:
			k = i
			break
	print(sum(b[:k] + a[k:]))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	(a, b) = (list(map(int, input().split())), list(map(int, input().split())))
	for j in range(len(a)):
		if k != 0:
			maxb = max(b)
			mina = min(a)
			if mina < maxb:
				a[a.index(mina)] = maxb
			b.remove(maxb)
			k -= 1
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr_a = sorted(list(map(int, input().split())))
	arr_b = sorted(list(map(int, input().split())))
	sum_a = sum(arr_a)
	if True:
		i = n - 1
		j = 0
		while k:
			k -= 1
			sum_a = max(sum_a, sum_a - arr_a[j] + arr_b[i])
			i -= 1
			j += 1
		print(sum_a)


for x1 in range(int(input())):
	(n, k) = map(int, input().strip().split()[:2])
	a = list(map(int, input().strip().split()[:n]))
	b = list(map(int, input().strip().split()[:n]))
	k1 = a + b
	k1.sort()
	p = 1
	z = []
	for x in range(len(k1) - 1, -1, -1):
		if len(z) == n:
			break
		elif k1[x] in a:
			z.append(k1[x])
			a.remove(k1[x])
		elif p <= k:
			if k1[x] in b:
				z.append(k1[x])
				b.remove(k1[x])
				p += 1
	print(sum(z))


t = int(input())
while t > 0:
	(a, k) = map(int, input().split())
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	for i in range(k):
		if min(l1) < max(l2):
			l1[l1.index(min(l1))] = max(l2)
			l2.remove(max(l2))
		else:
			break
	print(sum(l1))
	t -= 1


t = int(input())
cond_list = []
for i in range(t):
	tmp = []
	tmp.append(tuple(map(int, input().split())))
	tmp.append(sorted(list(map(int, input().split()))))
	tmp.append(sorted(list(map(int, input().split())), reverse=True))
	cond_list.append(tmp)
for tmp in cond_list:
	summ = 0
	j = 0
	for i in range(tmp[0][1]):
		if tmp[2][i] > tmp[1][j]:
			j += 1
			summ += tmp[2][i]
	print(summ + sum(tmp[1][j:]))


def solve(size, swaps, A, B):
	A.sort()
	B.sort(reverse=True)
	(i, j) = (0, 0)
	while swaps and i < size and (j < size):
		if A[i] < B[j]:
			(A[i], B[j]) = (B[j], A[i])
			swaps -= 1
			i += 1
			j += 1
		else:
			break
	print(sum(A))
testCases = int(input())
while testCases:
	(N, K) = map(int, input().split())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	solve(N, K, A, B)
	testCases -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	s1.sort()
	s2.sort()
	j = n - 1
	ans = 0
	for i in range(n):
		if s1[i] <= s2[j] and k > 0:
			ans = ans + s2[j]
			j = j - 1
			k = k - 1
		else:
			ans = ans + s1[i]
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = list(map(int, input().split()))
	l.sort()
	m.sort(reverse=True)
	i = 0
	j = 0
	c = 1
	while i < n and j < n and (c <= k):
		if l[i] < m[j]:
			(l[i], m[j]) = (m[j], l[i])
			i += 1
			j += 1
			c += 1
		else:
			break
	print(sum(l))


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, k) = R()
	a = sorted(R())
	b = sorted(R())[::-1]
	print(sum([*map(max, a[:k], b[:k])] + a[k:]))


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	a = []
	a = list(map(int, input().split()))
	b = []
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	s = 0
	for i in range(0, n):
		if b[i] > a[i] and i < k:
			s = s + b[i]
		else:
			s = s + a[i]
	print(s)


import sys, bisect
from math import gcd
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().rstrip().split())
t = inp()
for _ in range(t):
	(n, k) = invr()
	a = inlt()
	b = inlt()
	a.sort()
	b.sort(reverse=True)
	ans = 0
	for i in range(k):
		amin = min(a)
		bmax = max(b)
		if amin < bmax:
			ans += bmax
			a.remove(amin)
			b.remove(bmax)
		else:
			break
	for i in a:
		ans += i
	print(ans)


T = int(input())

def ans(a, b, k):
	a = sorted(a)
	b = sorted(b)[::-1]
	for i in range(min(len(b), k)):
		a[i] = max(a[i], b[i])
	return sum(a)
for t in range(T):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	a = list((int(x) for x in input().split(' ')))
	b = list((int(x) for x in input().split(' ')))
	print(ans(a, b, k))


def solve():
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	while k != 0:
		if a[0] < b[-1]:
			temp = a[0]
			a[0] = b[-1]
			b[-1] = temp
			a.sort()
			b.sort()
			k -= 1
		else:
			print(sum(a))
			break
	else:
		print(sum(a))
t = int(input())
for i in range(t):
	solve()


from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)
mod = 1000000007
inf = int(1e+18)
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]

def inverse(a):
	return pow(a, mod - 2, mod)

def usearch(x, a):
	lft = 0
	rgt = len(a) + 1
	while rgt - lft > 1:
		mid = (rgt + lft) // 2
		if a[mid] <= x:
			lft = mid
		else:
			rgt = mid
	return lft

def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	s = sum(a)
	for i in range(k):
		if a[i] < b[-1 - i]:
			s += b[-1 - i] - a[i]
	print(s)

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


for _ in range(int(input())):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = 0
	var = 0
	for i in range(n):
		if b[-1] > a[-1] and k > var:
			ans = ans + b.pop()
			var += 1
		else:
			ans = ans + a.pop()
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for x in range(k):
		if min(a) < max(b):
			(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
	tot = 0
	for x in range(len(a)):
		tot += a[x]
	print(tot)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

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

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

def solve():
	(n, k) = rl()
	A = sorted(rl())
	B = sorted(rl())
	answer = 0
	(i, j) = (0, n - 1)
	while i < n:
		if A[i] < B[j] and k > 0:
			answer += B[j]
			k -= 1
			i += 1
			j -= 1
		else:
			answer += A[i]
			i += 1
	print(answer)
mode = 'T'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


t = int(input())
ans = [0] * t
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		mina = min(a)
		maxb = max(b)
		indexa = a.index(mina)
		indexb = b.index(maxb)
		if mina <= maxb:
			a[indexa] = maxb
			b[indexb] = mina
	ans[i] = sum(a)
for i in range(t):
	print(int(ans[i]))


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 bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().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(ii()):
	(n, k) = mi()
	arr = lii()
	brr = lii()
	arr.sort()
	brr.sort(reverse=True)
	for i in range(n):
		if k <= 0:
			break
		for j in range(n):
			if brr[i] > arr[i]:
				temp = arr[i]
				arr[i] = brr[i]
				brr[i] = temp
				k -= 1
			if k <= 0:
				break
	print(sum(arr))


for T in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	s = sum(a)
	mx = s
	while k:
		if b:
			p = b.pop()
			s -= a[i]
			s += p
			a[i] = p
			i += 1
			k -= 1
			mx = max(s, mx)
	print(mx)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lst1 = sorted(list(map(int, input().split())))
	lst2 = list(map(int, input().split()))
	lst2.sort(reverse=True)
	i = 0
	while i < k:
		if lst1[i] < lst2[i]:
			lst1[i] = lst2[i]
			i += 1
		else:
			break
	print(sum(lst1))


def ret_max(n, k, a, b):
	i = 0
	while min(a) < max(b) and i < k:
		mina = a.index(min(a))
		maxb = b.index(max(b))
		(a[mina], b[maxb]) = (b[maxb], a[mina])
		i += 1
	return sum(a)
num_lines = int(input()) * 3
lines = []
k = 0
while k < num_lines:
	lines.append([int(i) for i in input().split()])
	k += 1
i = 0
while i < len(lines):
	print(ret_max(lines[i][0], lines[i][1], lines[i + 1], lines[i + 2]))
	i += 3


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	aa = sorted(list(map(int, input().split())))
	bb = sorted(list(map(int, input().split())), reverse=True)
	cc = []
	if k == 0:
		print(sum(aa))
	else:
		for x in range(k):
			if aa[x] > bb[x]:
				continue
			else:
				aa[x] = bb[x]
		print(sum(aa))


import heapq
t = int(input())
for _ in range(t):
	nk = [int(x) for x in input().split()]
	n = nk[0]
	k = nk[1]
	a = [int(y) for y in input().split()]
	b = [int(z) for z in input().split()]
	a.sort()
	b.sort(reverse=True)
	c = 0
	i = 0
	res = 0
	while c < k and i < n:
		if b[i] > a[i]:
			res = res + b[i]
			c = c + 1
		else:
			res = res + a[i]
		i = i + 1
	while i < len(a):
		res = res + a[i]
		i = i + 1
	print(res)


t = int(input())
for test in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	p = 0
	while k > 0 and p < n:
		if a[p] >= b[-1]:
			break
		(a[p], b[-1]) = (b[-1], a[p])
		b.sort()
		p += 1
		k -= 1
	print(sum(a))


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	e = []
	for j in range(0, n):
		e.append([c[j], 1])
	for j in range(0, n):
		e.append([d[j], 2])
	e.sort()
	e.reverse()
	s = 0
	a = 0
	b = 0
	j = 0
	while b < n:
		if e[j][1] == 1:
			s += e[j][0]
			b += 1
		elif e[j][1] == 2 and a < k:
			s += e[j][0]
			b += 1
			a += 1
		j += 1
	print(s)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	ans = 0
	for i in range(k):
		if a[i] < b[i]:
			ans += b[i]
		else:
			ans += a[i]
	print(ans + sum(a[k:]))


t = int(input())
for ex in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	i = 0
	while i < k and a[i] < b[i]:
		a[i] = b[i]
		i += 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:n]
	l = 0
	while l < k:
		min_a = min(a)
		max_b = max(b)
		if min_a > max_b:
			break
		minpos_a = a.index(min_a)
		maxpos_b = b.index(max_b)
		a[minpos_a] = max_b
		b[maxpos_b] = min_a
		l += 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split(' ')))
	temp = input().split(' ')
	a = list(map(int, temp))
	temp1 = input().split(' ')
	b = list(map(int, temp1))
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[-1]:
			a[i] = b.pop()
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	A = sorted(list(map(int, input().split())))
	B = sorted(list(map(int, input().split())))
	result = 0
	for i in range(n):
		if B[-1] > A[-1] and k > 0:
			result += B.pop()
			k -= 1
		else:
			result += A.pop()
	print(result)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort()
	a.sort(reverse=True)
	ans = 0
	while k > 0:
		ans += max(a[-1], b[-1])
		k -= 1
		del a[-1]
		del b[-1]
	fuck = sum(a[:n - k])
	print(ans + fuck)


t = int(input())
n = []
k = []
a = []
b = []
for i in range(t):
	(nt, kt) = map(int, input().split())
	n.append(nt)
	k.append(kt)
	at = list(map(int, input().split()))
	bt = list(map(int, input().split()))
	a.append(at)
	b.append(bt)
for i in range(t):
	for j in range(k[i]):
		if min(a[i]) < max(b[i]):
			minVal = min(a[i])
			maxVal = max(b[i])
			a[i].remove(min(a[i]))
			b[i].remove(max(b[i]))
			a[i].append(maxVal)
			b[i].append(minVal)
	print(sum(a[i]))


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		for i in range(k):
			min_a = min(a)
			max_b = max(b)
			if min_a >= max_b:
				break
			a.remove(min_a)
			b.remove(max_b)
			a.append(max_b)
			b.append(min_a)
		print(sum(a))
main()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	l = []
	m = []
	for i in range(k):
		if b[i] > a[i]:
			l.append(b[i])
	a.sort(reverse=True)
	for j in range(n - len(l)):
		l.append(a[j])
	print(sum(l))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)[::-1]
	ans = sum(a)
	for i in range(k):
		ans = max(ans, ans - a[i] + b[i])
	print(ans)
	t -= 1


from sys import stdout
import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	counter = 0
	for i in range(n):
		if counter >= k:
			break
		if a[i] < b[i]:
			a[i] = b[i]
			counter += 1
	stdout.write(str(sum(a)) + '\n')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(y) for y in input().split()])[::-1]
	for i in range(n):
		if k <= 0:
			break
		if a[i] >= b[i]:
			break
		else:
			(a[i], b[i]) = (b[i], a[i])
			k -= 1
	print(sum(a))


Test = int(input())
for i in range(Test):
	(a, k) = map(int, input().split(' '))
	array_a = list(map(int, input().split(' ')))
	array_b = list(map(int, input().split(' ')))
	sum1 = 0
	sum2 = 0
	sum3 = 0
	for i in range(len(array_a)):
		sum1 = sum1 + array_a[i]
	for j in range(len(array_b)):
		sum2 = sum2 + array_b[j]
	array_a.sort()
	array_b.sort(reverse=True)
	for c in range(0, k):
		if array_a[c] < array_b[c]:
			array_a[c] = array_b[c]
	print(sum(array_a))


for _ in range(int(input())):
	arr = list(map(int, input().split(' ')))
	n = arr[0]
	k = arr[1]
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort()
	sum = 0
	for i in range(len(a)):
		sum += a[i]
	for x in range(k):
		if a[x] < b[n - 1 - x]:
			sum -= a[x]
			sum += b[n - 1 - x]
	print(sum)


t = int(input())
res = [0 for _ in range(t)]
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for l in range(n if k > n else k):
		u = min(a)
		v = max(b)
		if v > u:
			res[i] += v
		else:
			res[i] += u
		a.remove(u)
		b.remove(v)
	res[i] += sum(a)
for i in range(t):
	print(res[i])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = sorted(list(map(int, input().split())))
	l2 = sorted(list(map(int, input().split())), reverse=True)
	for i in range(n):
		if k == 0:
			break
		if l2[i] > l1[i]:
			(l2[i], l1[i]) = (l1[i], l2[i])
			k -= 1
	print(sum(l1))


x = int(input())
for i in range(x):
	w = list(input().split())
	y = list(input().split())
	z = list(input().split())
	j = 0
	for i in y:
		y[j] = int(i)
		j += 1
	j = 0
	for i in z:
		z[j] = int(i)
		j += 1
	j = 0
	z.sort(reverse=True)
	for k in range(int(w[1])):
		y.append(z[k])
		y.remove(min(y))
	sum = 0
	for i in range(len(y)):
		sum += y[i]
	print(sum)


t = int(input())
while t > 0:
	t = t - 1
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	if k == 0 or min(a) >= max(b):
		print(sum(a))
	else:
		a.sort()
		b.sort(reverse=True)
		for j in range(k):
			if b[j] > a[j]:
				a[j] = b[j]
		print(sum(a))


MOD = 1000000007

def solve(n, k, a, b):
	if k == 0:
		print(sum(a))
	else:
		ans = 0
		mina = min(a)
		maxb = max(b)
		temp = 0
		for i in range(k):
			if maxb >= mina:
				b.append(mina)
				a.append(maxb)
				b.remove(maxb)
				a.remove(mina)
				maxb = max(b)
				mina = min(a)
		print(sum(a))
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(n, k, a, b)


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	for i in range(k):
		if b[i] > a[i]:
			(a[i], b[i]) = (b[i], a[i])
	return sum(a)
for _ in range(int(input())):
	ans = solve()
	print(ans)


for tc in range(0, int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for x in range(0, k):
		if min(a) < max(b):
			(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	j = list(map(int, input().split()))
	l.sort()
	j.sort()
	j.reverse()
	for t in range(n):
		if j[t] > l[t] and k:
			(j[t], l[t]) = (l[t], j[t])
			k -= 1
	print(sum(l))


import heapq

def get_input():
	return list(map(lambda x: int(x), input().split()))

def main():
	t = int(input())
	for i in range(t):
		k = get_input()[1]
		a = get_input()
		b = get_input()
		b = list(map(lambda x: -x, b))
		heapq.heapify(a)
		heapq.heapify(b)
		for i in range(k):
			if -b[0] <= a[0]:
				break
			b_item = heapq.heappop(b)
			a_item = heapq.heapreplace(a, -b_item)
			heapq.heappush(b, -a_item)
		print(sum(a))
main()


for v in range(int(input())):
	(n, k) = map(int, input().split())
	x = [int(w) for w in input().split()]
	y = [int(w) for w in input().split()]
	d = sum(x)
	a = sorted(x)
	b = sorted(y)
	for i in range(k):
		d = sum(a)
		(a[i], b[n - i - 1]) = (b[n - i - 1], a[i])
		if sum(a) < d:
			break
		d = sum(a)
	print(d)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = n - 1
	sum = 0
	while k > 0 or n > 0:
		if k > 0:
			if a[i] < b[j]:
				sum += b[j]
				j -= 1
				i += 1
				k -= 1
				n -= 1
			else:
				k = 0
		else:
			sum += a[i]
			i += 1
			n -= 1
	print(sum)


class Solution:

	def __init__(self):
		(self.n, self.k) = map(int, input().split())
		self.a = sorted(list(map(int, input().split())))
		self.b = sorted(list(map(int, input().split())), reverse=True)
		self.ans = 0

	def solution(self):
		for i in range(0, self.n):
			if i < self.k:
				self.ans += max(self.a[i], self.b[i])
			else:
				self.ans += self.a[i]
		print(self.ans)

def main():
	for _ in range(int(input())):
		ob = Solution()
		ob.solution()
main()


for _ in range(int(input())):
	(n, k) = [int(s) for s in input().split()]
	a = sorted([int(s) for (i, s) in enumerate(input().split())])
	b = sorted([int(s) for (i, s) in enumerate(input().split())], reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))


import sys
input = sys.stdin.readline

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = sorted(map(int, input().split()))
		b = sorted(map(int, input().split()))
		for c in range(k):
			i = c
			j = len(b) - (1 + c)
			if a[i] >= b[j]:
				break
			(a[i], b[j]) = (b[j], a[j])
		print(sum(a))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	if k == 0:
		print(sum(a))
		continue
	a.sort()
	b.sort(reverse=True)
	a1 = 0
	b1 = 0
	for i in range(k):
		if b[b1] > a[a1]:
			a[a1] = b[b1]
			b1 += 1
			a1 += 1
		else:
			break
	print(sum(a))


t = int(input())
for i in range(t):
	d = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	c = 0
	b.sort(reverse=True)
	for j in range(d[0]):
		if b[j] > a[j]:
			c += 1
			if c <= d[1]:
				(b[j], a[j]) = (a[j], b[j])
			else:
				break
	print(sum(a))


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math

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

def stringListIn():
	return [x for x in stdin.readline().split()]

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

def stringIn():
	return stdin.readline().strip()
t = int(input())
while t > 0:
	t -= 1
	(n, k) = listIn()
	a = listIn()
	b = listIn()
	a = sorted(a)
	s = 0
	b = sorted(b, reverse=True)
	for i in range(k):
		if a[i] > b[i]:
			s += a[i]
		else:
			s += b[i]
	if k < n:
		s += sum(a[k:])
	print(s)


t = int(input())
while t:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	i = 0
	j = n - 1
	while k:
		temp = 0
		if B[j] > A[i]:
			(A[i], B[j]) = (B[j], A[i])
		elif B[j] == A[i]:
			break
		elif B[j] < A[i]:
			break
		i += 1
		j -= 1
		k -= 1
	print(sum(A))
	t -= 1


from sys import stdin
import math
a = int(stdin.readline())
for b in range(0, a):
	c = stdin.readline().split()
	N = int(c[0])
	K = int(c[1])
	A = stdin.readline().split()
	B = stdin.readline().split()
	a = list()
	b = list()
	for k in A:
		a.append(int(k))
	for l in B:
		b.append(int(l))
	a.sort()
	b.sort()
	p = 0
	sum = 0
	while p < K:
		if b[N - p - 1] > a[p]:
			sum += b[N - p - 1]
		else:
			sum += a[p]
		p += 1
	for t in range(K, N):
		sum += a[t]
	print(sum)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	c = 0
	i = 0
	j = 0
	ans = 0
	while c < k and i < n and (j < n):
		if a[i] < b[j]:
			ans += b[j]
			i += 1
			j += 1
			c += 1
		else:
			ans += a[i]
			i += 1
	while i < n:
		ans += a[i]
		i += 1
	print(ans)
	t -= 1


t = int(input())

def swapp(a, b):
	mna = min(a)
	mxb = max(b)
	a.remove(mna)
	b.remove(mxb)
	a.append(mxb)
	b.append(mna)
	return a
	return b
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	inisum = sum(a)
	newsum = sum(a)
	for j in range(k):
		swapp(a, b)
		if sum(a) > inisum:
			inisum = sum(a)
		else:
			break
	print(inisum)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = 0
	for j in range(k):
		if a[0] >= b[-1]:
			break
		a.append(b[-1])
		b.insert(0, a[0])
		b.pop()
		a.pop(0)
		a.sort()
		b.sort()
	for j in a:
		ans += j
	print(ans)


def scambio_array(a, b, k):
	a.sort()
	b.sort()
	b.reverse()
	z = 0
	for i in range(k):
		if a[i] < b[i]:
			z = a[i]
			a[i] = b[i]
			b[i] = z
	print(sum(a))
T = int(input())
for i in range(T):
	(N, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	scambio_array(a, b, k)


from sys import stdin, stdout
import collections
import heapq
import itertools
import functools

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

def read_int():
	return int(read_line())

def read_arr():
	return read_line().split(' ')

def read_int_arr():
	return [int(x) for x in read_arr()]

def main():
	T = read_int()
	for _ in range(T):
		(n, k) = read_int_arr()
		a = read_int_arr()
		b = read_int_arr()
		a.sort()
		b.sort()
		ai = 0
		bi = len(b) - 1
		res = sum(a)
		for _ in range(k):
			if b[bi] > a[ai]:
				res += b[bi] - a[ai]
			else:
				break
			ai += 1
			bi -= 1
		print(res)
main()


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	c = len(b)
	for i in range(k):
		a[i] = max(a[i], b[c - i - 1])
	d = sum(a)
	print(d)


t = int(input())
for case in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = len(a) - 1
	while i < len(a) and j >= 0 and (k != 0):
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
		i += 1
		j -= 1
		k -= 1
	print(sum(a))


t = int(input())
for tc in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if k == 0:
		print(sum(a))
		continue
	a.sort()
	b.sort()
	b = b[::-1]
	o = 0
	flag = True
	while flag:
		for i in range(n):
			if not flag:
				break
			for j in range(n):
				if not flag:
					break
				if b[j] > a[i]:
					(a[i], b[j]) = (b[j], a[i])
					o += 1
					if o == k:
						flag = False
		break
	print(sum(a))


try:
	t = int(input())
	while t > 0:
		t = t - 1
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a.sort()
		maxi = sum(a)
		b.sort()
		b = b[::-1]
		while k > 0:
			k = k - 1
			if b[0] > a[0]:
				maxi = maxi - a[0]
				maxi = maxi + b[0]
				a.pop(0)
				b.pop(0)
			else:
				break
		print(maxi)
except Exception:
	pass


tests = int(input())
for i in range(tests):
	numbers = input().split(' ')
	n = int(numbers[0])
	k = int(numbers[1])
	text_a = input().split(' ')
	text_b = input().split(' ')
	a = []
	b = []
	for j in range(n):
		a.append(int(text_a[j]))
		b.append(int(text_b[j]))
	a.sort(reverse=True)
	b.sort(reverse=True)
	s = 0
	swap = 0
	step = 0
	a_counter = 0
	b_counter = 0
	while step < n:
		step += 1
		if swap < k:
			if a[a_counter] < b[b_counter]:
				s += b[b_counter]
				swap += 1
				b_counter += 1
			else:
				s += a[a_counter]
				a_counter += 1
		else:
			s += a[a_counter]
			a_counter += 1
	print(s)


for _ in range(int(input())):
	(_, swaps) = map(int, input().split())
	(a, b) = (sorted(map(int, input().split())), sorted(map(int, input().split()), reverse=True))
	for i in range(swaps):
		if b[i] > a[i]:
			(a[i], b[i]) = (b[i], a[i])
		else:
			break
	print(sum(a))


t = int(input())
for c in range(t):
	(n, k) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	i = 0
	while k and i < n:
		if a[i] < b[i]:
			aux = a[i]
			a[i] = b[i]
			b[i] = aux
			k -= 1
		i += 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	a.sort(reverse=True)
	s = 0
	c = 0
	v = 0
	va = 0
	vb = 0
	while v != n:
		if c >= k:
			s += a[va]
			va += 1
		elif a[va] > b[vb]:
			s += a[va]
			va += 1
		else:
			c += 1
			s += b[vb]
			vb += 1
		v += 1
	print(s)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	b = list(map(int, input().split()))[:n]
	for j in range(k):
		p = min(a)
		q = max(b)
		if p >= q:
			break
		else:
			a.remove(p)
			a.append(q)
			b.remove(q)
			b.append(p)
	sm = 0
	for s in range(n):
		sm = sm + a[s]
	print(sm)
	t = t - 1


import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = pow(10, 9) + 7

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

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

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

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def solve():
	(n, k) = sep()
	a = sorted(lis())
	b = sorted(lis())
	for i in range(0, k):
		if a[i] < b[n - (i + 1)]:
			a[i] = b[n - (i + 1)]
		else:
			break
	out(sum(a))
	nextline()
testcase(int(inp()))


from collections import defaultdict as dfd
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	val = 0
	for i in range(len(B) - 1, -1, -1):
		if k > 0:
			if B[i] > A[n - i - 1]:
				val += B[i]
				k -= 1
			else:
				val += A[n - i - 1]
		else:
			val += A[n - i - 1]
	print(val)


import math
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	while k:
		if a[0] < b[-1]:
			(a[0], b[-1]) = (b[-1], a[0])
			a.sort()
			b.sort()
			k -= 1
		else:
			break
	print(sum(a))


t = int(input())
for i in range(t):
	nk = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	bPointer = nk[0] - 1
	aPointer = 0
	for i in range(nk[1]):
		if a[aPointer] < b[bPointer]:
			a[aPointer] = b[bPointer]
			aPointer += 1
			bPointer -= 1
		else:
			break
	print(sum(a))


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	summ = 0
	i = 0
	mini = min(n, k)
	while i < mini:
		summ += max(a[i], b[-i - 1])
		i += 1
	if k < n:
		for f in range(i, n):
			summ += a[f]
	print(summ)


t = int(input())

def solve():
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort()
	currSwap = n - 1
	for i in range(k):
		if arr2[currSwap] > arr1[i]:
			arr1[i] = arr2[currSwap]
			currSwap -= 1
	print(sum(arr1))
for i in range(t):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()))
	st = n - 1
	for i in range(k):
		for j in range(st, -1, -1):
			if b[j] > a[i]:
				(a[i], b[j]) = (b[j], a[i])
				st -= 1
				break
	print(sum(a))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	(a, b) = (sorted(list((int(num) for num in input().split()))), sorted(list((int(num) for num in input().split())), reverse=True))
	j = 0
	for i in range(k):
		if b[j] > a[i]:
			a[i] = b[j]
			j += 1
	print(sum(a))


n = int(input())
for i in range(n):
	count = 0
	(n, k) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	a.sort()
	b.sort(reverse=True)
	for (idx, i) in enumerate(a):
		if idx < k:
			if b[idx] > i:
				count += b[idx]
			else:
				count += i
		else:
			count += i
	print(count)


inp = input()
num_cases = int(inp)
for _ in range(num_cases):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for idx in range(k):
		if a[idx] < b[idx]:
			a[idx] = b[idx]
	print(sum(a))


f = int(input())
for q in range(f):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		if min(a) < max(b):
			d = max(b)
			k = 0
			kk = 0
			for j in range(len(b)):
				if b[j] == max(b) and kk == 0:
					b[j] = -1
					kk = 1
				if a[j] == min(a) and k == 0:
					a[j] = d
					k = 1
	print(sum(a))


def swap(size, max_swaps, a, b):
	a = sorted(a)
	b = sorted(b)
	for i in range(max_swaps):
		min_a = a[i]
		max_b = b[size - (i + 1)]
		if min_a < max_b:
			(a[i], b[size - (i + 1)]) = (max_b, min_a)
		else:
			break
	return sum(a)
n = int(input())
for _ in range(n):
	sk = input().split(' ')
	a = input().split(' ')
	b = input().split(' ')
	a = list(map(int, a))
	b = list(map(int, b))
	print(swap(int(sk[0]), int(sk[1]), a, b))


cases = int(input())
for _ in range(cases):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))[::-1]
	index = 0
	for i in range(len(a)):
		if index < k:
			if b[i] > a[i]:
				a[i] = b[i]
				index += 1
		else:
			break
	print(sum(a))


def f(n, k, a, b):
	a.sort()
	b.sort()
	b = list(reversed(b))
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
		k -= 1
	return sum(a)

def inpArray():
	s = input()
	return [int(x) for x in s.split(' ')]
for x in range(int(input())):
	[n, k] = inpArray()
	a = inpArray()
	b = inpArray()
	print(f(n, k, a, b))


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	list_a = list(map(int, input().split()))
	list_b = list(map(int, input().split()))
	for i in range(b):
		(am, bm) = (min(list_a), max(list_b))
		if am >= bm:
			break
		list_a.remove(am)
		list_a.append(bm)
		list_b.remove(bm)
		list_b.append(am)
	print(sum(list_a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	a.reverse()
	a = [0] + a
	pre = [0] * (n + 1)
	pre[0] = 0
	for i in range(n):
		pre[i + 1] = pre[i] + b[i]
	ans = 0
	val = 0
	for i in range(n + 1):
		req = n - i
		val += a[i]
		if req <= k:
			ans = max(ans, val + pre[req])
	print(ans)


def ans(a, b, n, k):
	for i in range(k):
		m = a.index(min(a))
		M = b.index(max(b))
		if max(b) <= min(a):
			break
		else:
			(a[m], b[M]) = (b[M], a[m])
	return sum(a)
t = int(input())
L = []
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	L.append(ans(a, b, n, k))
for l in L:
	print(l)


import sys
from os import path
if path.exists('C:/Users/prana/Desktop/sublime/input.txt'):
	sys.stdin = open('C:/Users/prana/Desktop/sublime/input.txt', 'r')
	sys.stdout = open('C:/Users/prana/Desktop/sublime/output.txt', 'w')

def solve():
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b = b[::-1]
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
		else:
			break
	print(sum(a))
T = 1
T = int(input())
for _ in range(1, T + 1):
	print('Case #', _, file=sys.stderr)
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	a.reverse()
	b.sort()
	b.reverse()
	count = 0
	sum1 = 0
	while k > 0 and count != n:
		if max(a) >= max(b):
			sum1 += max(a)
			a.remove(max(a))
			count += 1
		else:
			sum1 += max(b)
			b.remove(max(b))
			k = k - 1
			count += 1
	if k == 0 and count != n:
		sum1 = sum1 + sum(a[0:n - count])
	print(sum1)


a = int(input())
for i in range(a):
	(b, c) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	for j in range(c):
		if min(x) < max(y):
			x[x.index(min(x))] = max(y)
			y.remove(max(y))
	print(sum(x))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()])
	b.reverse()
	s = 0
	s1 = 0
	s2 = 0
	for j in range(n):
		if b[j] < a[j]:
			s = j
			break
		s1 += a[j]
		s2 += b[j]
	if j > k - 1:
		kl = sum(a) - sum(a[:k]) + sum(b[:k])
		print(kl)
	else:
		kl = sum(a) - s1 + s2
		print(kl)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	best = b[n - k:]
	worst = a[:k]
	nw = best + worst
	nw.sort()
	nw = nw[k:]
	print(sum(a) - sum(worst) + sum(nw))


import sys
t = int(input())
for _ in range(t):
	sumi = 0
	(n, k) = map(int, input().split())
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(x) for x in input().split()], reverse=True)
	for i in range(n):
		if k != 0:
			sumi += max(a[i], b[i])
			k -= 1
		else:
			sumi += a[i]
	print(sumi)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	arr1.sort()
	arr2 = list(map(int, input().split()))
	arr2.sort(reverse=True)
	for j in range(k):
		if arr1[j] < arr2[j]:
			arr1[j] = arr2[j]
	print(sum(arr1))


import sys, os

def f():
	args = list(map(int, input().split()))
	return args
if 'local' in os.environ:
	sys.stdin = open('./input.txt', 'r')

def solve():
	t = f()[0]
	for i in range(t):
		(n, k) = f()
		a = f()
		b = f()
		a = sorted(a)
		asum = sum(a)
		b = sorted(b, reverse=True)
		for j in range(min(n, k)):
			asum += max(0, b[j] - a[j])
		print(asum)
solve()


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [] * n
	b = [] * n
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	while k:
		x = min(a)
		x1 = a.index(x)
		y = max(b)
		if y < x:
			break
		y1 = b.index(y)
		t = a[x1]
		a[x1] = b[y1]
		b[y1] = t
		k = k - 1
	print(sum(a))


t = int(input())
for _ in range(0, t):
	(n, k) = map(int, input().split())
	a = [int(z) for z in input().split()]
	b = [int(z) for z in input().split()]
	a.sort()
	b.sort(reverse=True)
	for i in range(0, k):
		if a[i] < b[i]:
			temp = a[i]
			a[i] = b[i]
			b[i] = temp
	print(sum(a))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	i = 0
	while k > 0 and A[i] < B[n - 1 - i]:
		(A[i], B[n - 1 - i]) = (B[n - 1 - i], A[i])
		i += 1
		k -= 1
	print(sum(A))
	t -= 1


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	list_a = list(map(int, input().split()))
	list_b = list(map(int, input().split()))
	for j in range(m):
		if min(list_a) < max(list_b):
			list_a.remove(min(list_a))
			list_a.append(max(list_b))
			list_b.remove(max(list_b))
	print(sum(list_a))


test = int(input())
for i in range(test):
	(n, k) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	a.sort(key=int)
	b.sort(key=int)
	b1 = b[::-1]
	s = 0
	for i in range(k):
		if a[i] < b1[i]:
			s += b1[i]
		else:
			s += a[i]
	s += sum(a[k:])
	print(s)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	s = sum(a)
	a.sort()
	b.sort()
	cnt = 0
	while cnt < len(b) and cnt < len(a) and (cnt < k):
		if b[len(b) - cnt - 1] > a[cnt]:
			s += b[len(b) - cnt - 1] - a[cnt]
		cnt += 1
	print(s)


t = int(input())
for _ in range(t):
	l = list(map(int, input().strip().split()))
	n = l[0]
	k = l[1]
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
		else:
			continue
	print(sum(a))


import sys
import math
from collections import defaultdict

def solve(test):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))
test_cases = int(input())
for t in range(1, test_cases + 1):
	solve(t)


from sys import stdin as si

def evaluate(n, k, a, b):
	b.sort()
	b = b[::-1]
	a.sort()
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	return sum(a)
for i in range(int(si.readline().strip())):
	(n, k) = map(int, si.readline().strip().split())
	a = list(map(int, si.readline().strip().split()))
	b = list(map(int, si.readline().strip().split()))
	print(evaluate(n, k, a, b))


t = int(input())
for i in range(t):
	(size, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	s_a = sorted(a)
	s_b = sorted(b)
	s_b = s_b[::-1]
	for i in range(0, k):
		if s_a[0] < s_b[i]:
			(s_a[0], s_b[i]) = (s_b[i], s_a[0])
			s_a = sorted(s_a)
	sum = 0
	for i in s_a:
		sum += i
	print(sum)


import sys
t = sys.stdin.read().strip().split('\n')[1:]
l = []
for i in range(0, len(t), 3):
	(_, k) = map(int, t[i].split())
	l1 = sorted(map(int, t[i + 1].split()))
	l2 = sorted(map(int, t[i + 2].split()), reverse=True)
	for j in range(k):
		if l1[j] < l2[j]:
			l1[j] = l2[j]
	l.append(sum(l1))
print(*l, sep='\n')


import sys
input = sys.stdin.buffer.readline
for _ in [0] * int(input()):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for _ in range(k):
		min_a = min(a)
		max_b = max(b)
		if min_a >= max_b:
			break
		ind_a = a.index(min_a)
		ind_b = b.index(max_b)
		(a[ind_a], b[ind_b]) = (b[ind_b], a[ind_a])
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	s = list(map(int, input().split()))
	l.sort()
	s.sort()
	s.reverse()
	j = 0
	for i in range(k):
		if l[j] < s[j]:
			l[j] = s[j]
			j += 1
		else:
			break
	print(sum(l))


number_of_case = int(input())

def swap(nums1: list, nums2: list, k: int) -> int:
	nums1.sort()
	nums2.sort(reverse=True)
	for i in range(0, k):
		if nums2[i] > nums1[i]:
			nums1[i] = nums2[i]
	return sum(nums1)
result: list = []
for i in range(0, number_of_case):
	pre_condition = input().split(' ')
	number_of_array = pre_condition[0]
	k = int(pre_condition[1])
	nums1 = list(map(lambda str: int(str), input().split(' ')))
	nums2 = list(map(lambda str: int(str), input().split(' ')))
	result.append(swap(nums1, nums2, k))
for i in result:
	print(i)


t = int(input())
for test in range(0, t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	cont = 0
	for i in range(0, n):
		if cont == k:
			break
		if a[i] < b[i]:
			a[i] = b[i]
			cont += 1
		else:
			break
	print(sum(a))


def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = sorted(list(map(int, input().split())))
		b = sorted(list(map(int, input().split())), reverse=True)
		ans = 0
		for i in range(k + 1):
			ans = max(ans, sum(b[:i] + a[i:]))
		print(ans)
main()


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


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	a_sum = sum(a)
	b_sum = sum(b)
	h = 0
	t = n - 1
	while h < k and a[t] < b[h]:
		a_sum += b[h] - a[t]
		h += 1
		t -= 1
	print(a_sum)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	c = b[-1]
	for i in range(k):
		c = max(b)
		if a[i] < c:
			a[i] = c
			b.remove(c)
	print(sum(a))


number = int(input())
for i in range(number):
	inputStr = str(input())
	(n, k) = list(map(int, inputStr.split(' ')))
	inputStr = str(input())
	a = list(map(int, inputStr.split(' ')))
	inputStr = str(input())
	b = list(map(int, inputStr.split(' ')))
	if k == 0:
		print(sum(a))
	else:
		sumNow = sum(a)
		for i in range(k):
			bMax = max(b)
			aMin = min(a)
			if bMax > aMin:
				sumNow += bMax - aMin
				b.remove(bMax)
				a.remove(aMin)
				b.append(aMin)
				a.append(bMax)
			else:
				break
		print(sumNow)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	x.sort()
	y.sort(reverse=True)
	for i in range(k):
		if y[i] > x[i]:
			x[i] = y[i]
		else:
			break
	print(sum(x))


def sum(l):
	ret = 0
	for i in l:
		ret += i
	return ret

def solve():
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	asrt = sorted(a)
	bsrt = sorted(b, reverse=True)
	ans = sum(a)
	for i in range(k):
		if bsrt[i] > asrt[i]:
			ans -= asrt[i]
			ans += bsrt[i]
		else:
			break
	print(ans)

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


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	b = sorted(list(map(int, input().split())), reverse=True)
	tot = sorted(a + b, reverse=True)
	pnt = 0
	while pnt < n and k:
		if a[pnt] < tot[0]:
			a[a.index(min(a))] = tot[0]
			a = sorted(a, reverse=True)
			k -= 1
		if a[pnt] == tot[0]:
			tot = tot[1:]
		pnt += 1
	print(sum(a))


from collections import Counter, defaultdict, deque
from math import *
import sys
input = sys.stdin.readline

def solve():
	(n, k) = [int(x) for x in input().split()]
	a1 = [int(x) for x in input().split()]
	a2 = [int(x) for x in input().split()]
	a1.sort()
	a2.sort(reverse=True)
	p = 0
	while k and p < n:
		if a1[p] < a2[p]:
			a1[p] = a2[p]
			k -= 1
		p += 1
	print(sum(a1))
tt = int(input())
for test in range(tt):
	solve()


import sys
input = sys.stdin.readline
inputLines = sys.stdin.readlines

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

def readStrList():
	return list(map(lambda x: x.strip(), inputLines()))

def indexOf(l: list, elem: int):
	return l.index(elem) if elem in l else -1

def lastIndexOf(l: list, elem: int):
	indexes = [idx for (idx, val) in enumerate(l) if val == elem]
	return max(indexes) if len(indexes) > 0 else -1

def solution():
	for _ in range(int(input())):
		data = readIntList()
		k = data[1]
		a = readIntList()
		b = readIntList()
		for _ in range(k):
			minA = indexOf(a, min(a))
			maxB = indexOf(b, max(b))
			if a[minA] < b[maxB]:
				(a[minA], b[maxB]) = (b[maxB], a[minA])
		print(sum(a))
solution()


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().rstrip().split())
	A = list(map(int, input().rstrip().split()))
	B = list(map(int, input().rstrip().split()))
	A.sort()
	B.sort()
	for i in range(k):
		if A[i] >= B[-(i + 1)]:
			break
		A[i] = B[-(i + 1)]
	print(sum(A))


def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		(n, k) = [int(x) for x in input().split()]
		a = [int(x) for x in input().split()]
		b = [int(x) for x in input().split()]
		a.sort()
		b.sort(reverse=True)
		for i in range(n):
			if b[i] <= a[i] or k <= 0:
				break
			else:
				a[i] = b[i]
				k -= 1
		print(sum(a))
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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()


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()])
	cont = 0
	S = 0
	while cont < k and b[-1] > a[0]:
		S += b[-1]
		b.pop(-1)
		a.pop(0)
		cont += 1
	for i in range(n - cont):
		S += a[i]
	print(S)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(m):
		if min(a) < max(b):
			a.remove(min(a))
			a.append(max(b))
			b.remove(max(b))
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	result = 0
	for i in range(k):
		result = result + max(a[i], b[i])
	result = result + sum(a[k:])
	print(result)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	count = 0
	s = 0
	q = 0
	for i in a:
		s = s + i
	for i in b:
		q = q + i
	l = 0
	if max(b) > min(a):
		for i in range(k):
			a.remove(min(a))
			a.append(max(b))
			b.remove(max(b))
			b.append(min(a))
		for j in a:
			count = count + j
			if count > l:
				l = count
		print(l)
	else:
		print(s)


for _ in range(int(input())):
	(N, K) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort(reverse=True)
	maxa = sum(A)
	for i in range(K):
		maxa = max(maxa, maxa - A[i] + B[i])
	print(maxa)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	for i in a:
		l.append(i)
	for i in b:
		l.append(i)
	l.sort()
	s = 0
	i = 2 * n - 1
	c = 0
	while i >= 0 and c < n:
		if l[i] not in a and l[i] in b and (k > 0):
			s = s + l[i]
			k = k - 1
			b.remove(l[i])
			c += 1
		elif l[i] in a:
			s = s + l[i]
			a.remove(l[i])
			c += 1
		i = i - 1
	print(s)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	index = 0
	count = 0
	for j in range(len(b)):
		num = b[j]
		if count == k:
			break
		if index < len(a):
			flag = 0
			for l in range(index, len(a)):
				if num > a[l]:
					a[l] = num
					index = l + 1
					flag = 1
					count += 1
					break
			if flag == 0:
				index = l
		else:
			break
	print(sum(a))


a = int(input())
for x in range(a):
	(b, c) = map(int, input().split())
	d = list(map(int, input().split()))
	e = list(map(int, input().split()))
	for y in range(c):
		if min(d) >= max(e):
			break
		else:
			p = d.index(min(d))
			n = e.index(max(e))
			(d[p], e[n]) = (e[n], d[p])
	print(sum(d))


def ab():
	(b, c) = map(int, input().split())
	e = list(map(int, input().split()))
	f = list(map(int, input().split()))
	e = sorted(e)
	f = sorted(f, reverse=True)
	for i in range(0, c):
		if e[i] < f[i]:
			temp = e[i]
			e[i] = f[i]
			f[i] = temp
	print(sum(e))
for i in range(0, int(input())):
	ab()


from sys import stdin, stdout
from collections import deque, defaultdict
import math as m
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()
rli = lambda : map(int, stdin.readline().split())
(INF, NINF) = (float('inf'), float('-inf'))

def main():
	T = int(rl())
	for _ in range(T):
		(n, k) = rli()
		A = list(rli())
		B = list(rli())
		ans = 0
		A.sort()
		B.sort(reverse=True)
		sa = sum(A)
		ans = sa
		for i in range(k):
			sa -= A[i]
			sa += B[i]
			ans = max(ans, sa)
		print(ans)
	stdout.close()
main()


l = [1, 2, 3, 4, 45, 6]
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	if k == 0:
		print(sum(a))
	else:
		c = []
		c.append(sum(a))
		for i in range(k):
			(a[i], b[i]) = (b[i], a[i])
			c.append(sum(a))
		print(max(c))


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	a.sort()
	ans = 0
	for i in range(k):
		if b[i] > a[i]:
			ans += b[i]
		else:
			ans += a[i]
	for i in range(k, n):
		ans += a[i]
	print(ans)


from math import ceil, sqrt, gcd, log2
from itertools import groupby, zip_longest
from functools import reduce
from collections import defaultdict, Counter
from heapq import nsmallest, nlargest
for q in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	i = 0
	j = 0
	while k > 0:
		k -= 1
		if a[i] < b[j]:
			a[i] = b[j]
			i += 1
			j += 1
		else:
			break
	print(sum(a))


def read():
	return list(map(int, input().split()))
for i in range(int(input())):
	(n, k) = read()
	a = sorted(read())
	b = sorted(read())
	ans = sum(a[k:])
	for i in range(k):
		ans += max(a[i], b[~i])
	print(ans)


t = int(input())
for i in range(t):
	(n, max_moves) = map(int, input().split())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	a = sorted(a)
	b = sorted(b)
	for i in range(max_moves):
		if a[i] < b[-1 - i]:
			(a[i], b[-1 - i]) = (b[-1 - i], a[i])
		else:
			break
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		if min(a) < max(b):
			i = 0
			a1 = a.index(min(a))
			a2 = b.index(max(b))
			a[a1] = max(b)
			b[a2] = min(a)
		else:
			break
	print(sum(a))


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	B = B[::-1]
	for i in range(0, k):
		if A[i] < B[i]:
			A[i] = B[i]
		else:
			break
	print(sum(A))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr.sort(reverse=True)
	t = []
	brr.sort()
	while k and arr:
		if arr[-1] >= brr[-1]:
			k = 0
		else:
			t.append(brr[-1])
			arr.pop()
			brr.pop()
			k -= 1
	print(sum(t) + sum(arr))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	for q in range(k):
		if a[q] < b[q]:
			(a[q], b[q]) = (b[q], a[q])
		else:
			break
	print(sum(a))


t = int(input())
i = 0
while i < t:
	(s, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		if min(a) < max(b):
			o = a.index(min(a))
			o1 = b.index(max(b))
			(a[o], b[o1]) = (b[o1], a[o])
	print(sum(a))
	i += 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	a.extend(b[:k])
	a.sort(reverse=True)
	print(sum(a[:n]))


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	rtn = 0
	for x in range(k):
		if a[x] < b[x]:
			rtn += b[x]
		else:
			rtn += a[x]
	if k < n:
		s = sum(a[k:])
		rtn += s
	print(rtn)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ind = 0
	kp = 0
	while kp < k and ind < n:
		if b[ind] >= a[ind]:
			(b[ind], a[ind]) = (a[ind], b[ind])
			kp += 1
			ind += 1
		else:
			break
	print(sum(a))


t = int(input())
lst = []
for x in range(t):
	(n, k) = input().split()
	k = int(k)
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	for x in range(k):
		l1 = sorted(l1)
		l2 = sorted(l2)[::-1]
		if l1[0] < l2[0]:
			(l1[0], l2[0]) = (l2[0], l1[0])
	lst.append(sum(l1))
for r in lst:
	print(r)


t = int(input())
for tt in range(0, t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(a)
	if k == 0:
		print(s)
		continue
	a.sort()
	b.sort(reverse=True)
	j = 0
	for i in range(0, k):
		if a[i] >= b[i]:
			break
		else:
			t = b[i]
			b[i] = a[i]
			a[i] = t
			j += 1
	s = sum(a)
	print(s)


for j in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for z in range(k):
		if min(a) <= max(b):
			ia = a.index(min(a))
			ib = b.index(max(b))
			(a[ia], b[ib]) = (b[ib], a[ia])
		else:
			break
	print(sum(a))


import math
import functools

def s():
	(n, k) = list(map(int, input().split(' ')))
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	a.sort()
	b.sort(reverse=True)
	ans = sum(a)
	for i in range(k):
		if b[i] > a[i]:
			ans = ans - a[i] + b[i]
		else:
			break
	print(ans)
t = int(input())
for i in range(t):
	s()


t = int(input())
s = []
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	while k > 0:
		if min(a) < max(b):
			(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
		k -= 1
	s.append(sum(a))
print(*s, sep='\n')


q = int(input())
for i in range(q):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	ch = 0
	while k > 0 and ch < n and (a[ch] <= b[-ch - 1]):
		if a[ch] < b[-ch - 1]:
			a[ch] = b[-ch - 1]
			k -= 1
		ch += 1
	print(sum(a))


ans = ''
num = int(input())
for i in range(num):
	(n, k) = map(int, input().split())
	lsa = list(map(int, input().split()))
	lsb = list(map(int, input().split()))
	mx = max(lsb)
	mn = min(lsa)
	while mx > mn and k > 0:
		temp = mx
		lsb[lsb.index(mx)] = mn
		lsa[lsa.index(mn)] = mx
		mx = max(lsb)
		mn = min(lsa)
		k -= 1
	ans += f'{sum(lsa)}\n'
print(ans)


import sys
lines = []
for Line in sys.stdin:
	lines.append(Line.rstrip('\n'))
q = lines[0]
q = int(q)
del lines[0]
for i in range(q):
	(n, m) = list(map(int, lines[0].split()))
	del lines[0]
	a = sorted(list(map(int, lines[0].split())))
	del lines[0]
	b = sorted(list(map(int, lines[0].split())))[::-1]
	del lines[0]
	for i in range(m):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))


test_cases = int(input())
for _ in range(test_cases):
	(n, k) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	for b_number in sorted(b)[n - k:]:
		if b_number > min(a):
			a[a.index(min(a))] = b_number
	print(sum(a))


import sys
ints = (int(x) for x in sys.stdin.read().split())
sys.setrecursionlimit(3000)

def main():
	ntc = next(ints)
	for tc in range(1, ntc + 1):
		(n, k) = (next(ints) for i in range(2))
		a = sorted([next(ints) for i in range(n)], reverse=1)
		b = sorted([next(ints) for i in range(n)])
		ans = s = sum(a)
		for i in range(k):
			s = s + b.pop() - a.pop()
			ans = max(ans, s)
		print(ans)
	return
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()))
	a.sort()
	b.sort(reverse=True)
	i = 0
	j = 0
	r = 0
	while j <= n - 1 and i <= n - 1:
		if r == m:
			break
		if a[i] < b[j]:
			a[i] = b[j]
			i += 1
			j += 1
			r += 1
		else:
			break
	print(sum(a))


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

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 swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(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
MAXN = int(1000000.0 + 5)

def spf_sieve():
	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, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]
spf_sieve()

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(n, k) = int_array()
	a = int_array()
	b = int_array()
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))


def main():
	(n, k) = (int(x) for x in input().split())
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(x) for x in input().split()], reverse=True)
	pos = 0
	while pos < k and a[pos] < b[pos]:
		pos += 1
	ans = 0
	for i in range(0, n):
		if i < pos:
			ans += b[i]
		else:
			ans += a[i]
	return ans
t = int(input())
while t > 0:
	t -= 1
	print(main())


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	for i in range(k):
		(num1, num2) = (a.pop(0), b.pop(0))
		a.append(max(num1, num2))
	print(sum(a))


t = int(input())
for i in range(t):
	str3 = input()
	lst = str3.split()
	n = int(lst[0])
	k = int(lst[1])
	str1 = input()
	str2 = input()
	a = str1.split()
	b = str2.split()
	for j in range(n):
		a[j] = int(a[j])
		b[j] = int(b[j])
	sum1 = 0
	a.sort()
	b.sort(reverse=True)
	count = 0
	j = 0
	while k > 0 and count < n and (j < n):
		if b[count] > a[j]:
			temp = a[j]
			a[j] = b[count]
			b[count] = temp
			k -= 1
			j += 1
			count += 1
		else:
			count += 1
	for j in range(n):
		sum1 += a[j]
	print(sum1)


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	while i < k:
		mna = min(a)
		mxb = max(b)
		if mna < mxb:
			a.remove(a[a.index(min(a))])
			a.append(mxb)
			b.remove(b[b.index(max(b))])
			b.append(mna)
		else:
			break
		i = i + 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	i = 0
	while i < k and len(b) > 0 and (a[0] < b[-1]):
		a.pop(0)
		a.append(b.pop())
		i += 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	arr1 = map(int, input().split(' '))
	arr2 = map(int, input().split(' '))
	arrSum = 0
	if k > 0:
		sortArr1 = sorted(arr1)
		sortArr2 = sorted(arr2, reverse=True)
		for ind in range(k):
			if sortArr1[ind] < sortArr2[ind]:
				sortArr1[ind] = sortArr2[ind]
			arrSum = arrSum + sortArr1[ind]
		print(arrSum + sum(sortArr1[k:]))
	else:
		print(sum(arr1))


for i in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	ai = 0
	bi = 0
	while k > 0 and ai < n:
		if a[ai] < b[bi]:
			a[ai] = b[bi]
			bi += 1
			a.sort()
			k -= 1
			ai = 0
		else:
			ai += 1
	print(sum(a))


from math import *
from copy import *
from heapq import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(n, k, a, b):
	s1 = sum(a)
	s2 = sum(b)
	if k == 0:
		return s1
	a.sort(reverse=True)
	b.sort(reverse=True)
	(i, j) = (n - 1, 0)
	while k > 0:
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			j += 1
			i -= 1
			k -= 1
		else:
			break
	return max(sum(a), s1)
T = int(input())
for _ in range(T):
	(N, K) = list(map(int, stdin.readline().rstrip().split()))
	A = list(map(int, stdin.readline().rstrip().split()))
	B = list(map(int, stdin.readline().rstrip().split()))
	print(solve(N, K, A, B))


import sys
import threading

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

def find_path(graph, start, vis):
	vis[start] = 1
	if not vis[graph[start]]:
		find_path(graph, graph[start], vis)

def main():
	t = int(input())
	for i in range(t):
		(n, k) = get_numbers()
		a = list(get_numbers())
		b = list(get_numbers())
		a = sorted(a)
		b = sorted(b)
		a_ind = 0
		b_ind = len(b) - 1
		for ind in range(k):
			if a[a_ind] >= b[b_ind]:
				break
			a[a_ind] = b[b_ind]
			a_ind += 1
			b_ind -= 1
		print(sum(a))
sys.setrecursionlimit(1 << 30)
threading.stack_size(1 << 27)
main_thread = threading.Thread(target=main)
main_thread.start()
main_thread.join()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for i in range(n):
		c.append((a[i], 0))
		c.append((b[i], 1))
	c = sorted(c, reverse=True)
	ans = 0
	cnt = n
	i = 0
	while cnt > 0 and k > 0:
		if c[i][1] == 1:
			k -= 1
			cnt -= 1
			ans += c[i][0]
		else:
			cnt -= 1
			ans += c[i][0]
		i += 1
	while cnt > 0:
		if c[i][1] == 0:
			cnt -= 1
			ans += c[i][0]
		i += 1
	print(ans)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	while k:
		k -= 1
		a.sort()
		b.sort()
		if min(a) >= max(b):
			break
		(a[0], b[-1]) = (b[-1], a[0])
	print(sum(a))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	for i in range(b):
		m = l.index(min(l))
		n = l1.index(max(l1))
		if l[m] < l1[n]:
			(l[m], l1[n]) = (l1[n], l[m])
	print(sum(l))


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		min_a = min(a)
		max_b = max(b)
		if min_a < max_b:
			ind_a = a.index(min_a)
			ind_b = b.index(max_b)
			(a[ind_a], b[ind_b]) = (b[ind_b], a[ind_a])
		else:
			break
	print(sum(a))

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


from sys import stdin, stdout
from math import gcd, sqrt, floor, ceil
input = stdin.readline

def list_inp(x):
	return list(map(x, input().split()))

def map_inp(x):
	return map(x, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)
n = int(input())
for i in range(n):
	(a, b) = map_inp(int)
	arr1 = list_inp(int)
	arr2 = list_inp(int)
	arr1.sort()
	arr2 = sorted(arr2, reverse=True)
	cnt = 0
	for i in range(a):
		if b <= 0 or arr1[i] > arr2[i]:
			break
		arr1[i] = arr2[i]
		b -= 1
	print(sum(arr1))


def process(k):
	l = [int(x) for x in input().split()]
	g = [int(x) for x in input().split()]
	l.sort()
	g.sort(reverse=True)
	for i in range(0, len(l)):
		if k > 0:
			if l[i] > g[i]:
				continue
			else:
				l[i] = g[i]
				k -= 1
		else:
			break
	print(sum(l))

def main():
	t = int(input())
	for i in range(0, t):
		q = [int(x) for x in input().split()]
		k = q[1]
		process(k)
main()


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	b.reverse()
	sum = 0
	for j in range(k):
		sum += max(a[j], b[j])
	for j in range(k, n):
		sum += a[j]
	print(sum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	for i in range(k):
		if l1[i] < l2[n - i - 1]:
			l1[i] = l2[n - i - 1]
		else:
			break
	print(sum(l1))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == 1:
		a = int(input())
		b = int(input())
		if k == 0:
			print(a)
		else:
			print(max(a, b))
	else:
		a = sorted(list(map(int, input().split())))
		b = sorted(list(map(int, input().split())))
		b.reverse()
		ans = []
		need = []
		dust = []
		for i in range(n):
			if a[0] >= b[0]:
				ans.append(a[0])
				b.pop(0)
				a.pop(0)
			else:
				need.append(b[0])
				dust.append(a[0])
				a.pop(0)
				b.pop(0)
		while k > 0:
			if len(need) != 0:
				ans.append(need[0])
				need.pop(0)
				if len(dust) != 0:
					dust.pop(0)
			k -= 1
		print(sum(ans) + sum(dust))


import heapq
t = int(input())
for i in range(t):
	inps = list(map(lambda x: int(x), input().split()))
	(n, k) = (inps[0], inps[1])
	a = list(map(lambda x: int(x), input().split()))
	b = list(map(lambda x: -int(x), input().split()))
	heapq.heapify(a)
	heapq.heapify(b)
	for j in range(k):
		if -b[0] <= a[0]:
			break
		b_item = heapq.heappop(b)
		a_item = heapq.heappop(a)
		heapq.heappush(a, -b_item)
		heapq.heappush(b, -a_item)
	print(sum(a))


from bisect import insort

def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for _ in range(k):
		if a[0] < b[-1]:
			aa = a[0]
			bb = b[-1]
			a.pop(0)
			b.pop(-1)
			insort(a, bb)
			insort(b, aa)
		else:
			break
	print(sum(a))
for _ in range(int(input())):
	solve()


t = int(input())
while t:
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	for s in range(k):
		m1 = min(A)
		ind1 = A.index(m1)
		m2 = max(B)
		ind2 = B.index(m2)
		if m1 < m2:
			A[ind1] = m2
			B.remove(m2)
	print(sum(A))
	t -= 1


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	s = sum(a[k:n])
	c = a[0:k] + b[0:k]
	c.sort(reverse=True)
	s += sum(c[0:k])
	print(s)


num = int(input())
for i in range(num):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort()
	b.reverse()
	r = 0
	for j in range(n):
		if r == k:
			break
		if a[j] < b[j]:
			(a[j], b[j]) = (b[j], a[j])
			r += 1
	print(sum(a))


t = int(input())
for i in range(t):
	num = list(map(int, input().strip().split()))[:2]
	n = num[0]
	k = num[1]
	a = sorted(list(map(int, input().strip().split()))[:n])
	b = sorted(list(map(int, input().strip().split()))[:n], reverse=True)
	count = 0
	for i in range(n):
		if i < k and a[i] < b[i]:
			count += b[i]
		else:
			count += a[i]
	print(count)


import sys
data = sys.stdin.readlines()
filtered_data = []
for i in range(1, len(data)):
	filtered_data += [data[i].strip().split()]

def ascending(list):
	answer = [] + [int(list[-1])]
	list2 = list[:-1]
	for item in list2:
		i = 0
		inserted = int(item)
		while i <= len(answer) - 1 and inserted > answer[i]:
			i += 1
		answer[i:i] = [inserted]
	return answer
splitter_limit = len(filtered_data) // 3
sample_domain = range(splitter_limit)
final_sample_domain = []
for item in list(sample_domain):
	final_sample_domain += [3 * int(item)]
for position in final_sample_domain:
	step_count = int(filtered_data[position][1])
	if step_count != 0:
		good_list = ascending(filtered_data[position + 2])
		final_list = filtered_data[position + 1] + good_list[-step_count:]
		last_list = ascending(final_list)[-len(filtered_data[position + 2]):]
		answer = 0
		for item in last_list:
			answer += item
		print(answer)
	else:
		answer = 0
		for item in filtered_data[position + 1]:
			answer += int(item)
		print(answer)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	B.sort(reverse=True)
	A.sort()
	Ans = 0
	for i in range(k):
		Ans += max(A[i], B[i])
	Ans += sum(A[k:])
	print(Ans)


import sys
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()))
	a.sort()
	b.sort(reverse=True)
	for i in range(m):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


t = int(input())
for i in range(t):
	temp = input().split()
	n = int(temp[0])
	k = int(temp[1])
	a = input().split()
	a = [int(i) for i in a]
	b = input().split()
	b = [int(i) for i in b]
	a.sort(reverse=True)
	b.sort(reverse=True)
	s = 0
	for j in range(n - k):
		s = s + a[j]
	l = n - k
	m = 0
	for j in range(k):
		if b[m] > a[l]:
			s = s + b[m]
			m = m + 1
		else:
			s = s + a[l]
			l = l + 1
	print(s)


t = int(input())
for i in range(t):
	(n, k) = input().split()
	la = list(map(int, input().split()))[:int(n)]
	lb = list(map(int, input().split()))[:int(n)]
	la.sort()
	lb.sort(reverse=True)
	for i in range(int(k)):
		if la[i] < lb[i]:
			la[i] = lb[i]
	sum1 = 0
	for i in range(len(la)):
		sum1 += la[i]
	print(sum1)


import math
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())
test_cases = inp()
for _ in range(test_cases):
	(length_arr, max_moves) = map(int, input().split())
	a = inlt()
	b = inlt()
	a.sort()
	b.sort()
	for i in range(max_moves):
		if b[length_arr - 1] > a[i]:
			a[i] = b[length_arr - 1]
		else:
			break
		length_arr -= 1
	print(sum(a))


import math
t = int(input())
while t:
	line = input().split()
	(n, k) = (int(line[0]), int(line[1]))
	a = input().split()
	a = [int(x) for x in a]
	b = input().split()
	b = [int(x) for x in b]
	a.sort()
	b.sort()
	ans = 0
	for i in range(k):
		ans += max(a[i], b[n - i - 1])
	for i in range(k, n):
		ans += a[i]
	print(ans)
	t -= 1


T = int(input())
for t in range(T):
	(n, k) = [int(i) for i in input().split()]
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(i) for i in input().split()])
	i = 0
	j = n - 1
	ans = sum(a)
	while i < n and j >= 0 and (a[i] < b[j]) and (k > 0):
		ans = ans - a[i] + b[j]
		i += 1
		j -= 1
		k -= 1
	print(ans)


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	lsta = list(map(int, input().split()))
	lstb = list(map(int, input().split()))
	lsta.sort()
	lstb = sorted(lstb, reverse=True)
	for i in range(n):
		if m > 0:
			if lstb[i] > lsta[i]:
				(lsta[i], lstb[i]) = (lstb[i], lsta[i])
				m -= 1
		else:
			break
	print(sum(lsta))


t = int(input())
for i in range(t):
	result = []
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	result.append(sum(a))
	while k > 0:
		temp1 = min(a)
		temp2 = max(b)
		indx1 = a.index(temp1)
		indx2 = b.index(temp2)
		(a[indx1], b[indx2]) = (b[indx2], a[indx1])
		k = k - 1
		result.append(sum(a))
	print(max(result))


def swap(a, b):
	(min_a, max_b) = (min(a), max(b))
	if min_a < max_b:
		buff = a[a.index(min_a)]
		a[a.index(min_a)] = b[b.index(max_b)]
		b[b.index(max_b)] = buff
for i in range(int(input())):
	(n, k) = [int(elem) for elem in input().split()]
	(a, b) = ([int(elem) for elem in input().split()], [int(elem) for elem in input().split()])
	for i in range(k):
		swap(a, b)
	summ = 0
	for i in range(len(a)):
		summ += a[i]
	print(summ)


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(n, k) = map(int, sys.stdin.readline().split())
	list_a = list(map(int, sys.stdin.readline().split()))
	list_b = list(map(int, sys.stdin.readline().split()))
	list_a.sort()
	list_b.sort(reverse=True)
	for i in range(k):
		if list_a[i] > list_b[i]:
			break
		list_a[i] = list_b[i]
	print(sum(list_a))


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


for i in range(int(input())):
	(n, k) = map(int, input().split())
	data1 = list(map(int, input().split()))
	data2 = list(map(int, input().split()))
	for j in range(k):
		data1.sort()
		data2.sort(reverse=True)
		if data1[0] < data2[0]:
			(data1[0], data2[0]) = (data2[0], data1[0])
		else:
			break
	print(sum(data1))


from bisect import insort
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	ans = 0
	for i in range(n):
		if b[i] > a[i] and k > 0:
			ans += b[i]
			k -= 1
		else:
			ans += a[i]
	print(ans)


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	a_l = list(map(int, input().split()))
	b_l = list(map(int, input().split()))
	a_l.sort()
	b_l.sort()
	j = 0
	kk = n - 1
	i = 0
	while i < k:
		if a_l[j] < b_l[kk]:
			(a_l[j], b_l[kk]) = (b_l[kk], a_l[j])
			kk -= 1
			i += 1
			j += 1
		else:
			j += 1
		if kk < 0 or j >= n:
			break
	print(sum(a_l))
	t -= 1


t = int(input())
a = list()
b = list()
str = list()
otv = list()
for i in range(t):
	str = input().split(' ')
	n = int(str[0])
	k = int(str[1])
	str.clear()
	str = input().split(' ')
	for i in range(len(str)):
		a.append(int(str[i]))
	str.clear()
	str = input().split(' ')
	for i in range(len(str)):
		b.append(int(str[i]))
	if k == 0:
		otv.append(sum(a))
		a.clear()
		b.clear()
		str.clear()
		continue
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
		else:
			break
	otv.append(sum(a))
	a.clear()
	b.clear()
	str.clear()
for i in otv:
	print(i)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	max_sum = 0
	arr.sort()
	arr1.sort()
	arr1 = arr1[::-1]
	for i in range(n):
		if i < k:
			max_sum += max(arr[i], arr1[i])
		else:
			max_sum += arr[i]
	print(max_sum)


t = int(input())
for _ in range(0, t):
	(n, k) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	brr = list(map(int, input().split(' ')))
	a_curr_sum = sum(arr)
	arr = sorted(arr)
	brr = sorted(brr, reverse=True)
	count = 0
	for i in range(0, k):
		for i in range(0, len(arr)):
			(arr[i], brr[i]) = (brr[i], arr[i])
			temp = sum(arr)
			if a_curr_sum < temp and count < k:
				a_curr_sum = temp
			count += 1
	print(a_curr_sum)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	l = len(b)
	for j in range(k):
		if a[j] < b[l - 1]:
			a[j] = b[l - 1]
		l = l - 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	a = [int(a) for a in input().split()]
	b = [int(b) for b in input().split()]
	a.sort()
	b.sort(reverse=True)
	for k in range(m):
		if a[k] < b[k]:
			a[k] = b[k]
	sum1 = 0
	for j in a:
		sum1 = sum1 + j
	print(sum1)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, K, A, B):
	if K == 0:
		return sum(A)
	A.sort()
	B.sort()
	total = sum(A)
	i = 0
	j = len(B) - 1
	count = 0
	while A[i] < B[j] and count < K:
		total -= A[i]
		total += B[j]
		i += 1
		j -= 1
		count += 1
		if i == len(A) or j == -1:
			break
	return total
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N, K) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	ans = solve(N, K, A, B)
	print(ans)


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


t = int(input())
for _ in range(t):
	[n, k] = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = sorted(a)
	b = sorted(b, reverse=True)
	i = 0
	while k > 0 and a[i] < b[i]:
		a[i] = b[i]
		k -= 1
		i += 1
	sum = 0
	for i in a:
		sum += i
	print(sum)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()), reverse=True)
	s = 0
	for (i, (a_i, b_i)) in enumerate(zip(a, b)):
		if i < k:
			s += max(a_i, b_i)
		else:
			s += a_i
	print(s)


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	while k != 0:
		a = list1.index(min(list1))
		b = list2.index(max(list2))
		if list1[a] < list2[b]:
			(list1[a], list2[b]) = (list2[b], list1[a])
		else:
			break
		k -= 1
	print(sum(list1))
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	d = n - 1
	for i in range(k):
		for j in range(n):
			if b[d] > a[j]:
				a[j] = b[d]
				d -= 1
				break
	print(sum(a))


t = int(input(''))
while t > 0:
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	for i in range(1, k + 1):
		if l2[-i] > l1[0]:
			(l1[0], l2[-i]) = (l2[-i], l1[0])
			l1.sort()
		else:
			break
	print(sum(l1))
	t -= 1


DP = {}

def F(i, j, K, A, B):
	global DP
	if (i, j, K) in DP:
		return DP[i, j, K]
	if i == len(A):
		return 0
	if j == len(B):
		return A[i] + F(i + 1, j, K, A, B)
	if K == 0:
		return A[i] + F(i + 1, j, 0, A, B)
	if B[j] > A[i]:
		DP[i, j, K] = max(B[j] + F(i + 1, j + 1, K - 1, A, B), A[i] + F(i + 1, j, K, A, B), F(i, j + 1, K, A, B))
		return DP[i, j, K]
	DP[i, j, K] = max(A[i] + F(i + 1, j, K, A, B), F(i, j + 1, K, A, B))
	return DP[i, j, K]

def ProcessInputs():
	global DP
	(n, k) = map(int, input().strip().split())
	A = list(map(int, input().strip().split()))
	B = list(map(int, input().strip().split()))
	A.sort()
	B.sort()
	DP = {}
	print(F(0, 0, k, A, B))
T = int(input())
for _ in range(T):
	ProcessInputs()


t = int(input())
for r in range(1, t + 1):
	nk = [int(x) for x in input().split()]
	a = [int(y) for y in input().split()]
	b = [int(z) for z in input().split()]
	k = int(nk[1])
	for i in range(1, k + 1):
		mina = min(a)
		maxb = max(b)
		if mina < maxb:
			a.append(maxb)
			b.append(mina)
			a.remove(mina)
			b.remove(maxb)
		else:
			break
	print(sum(a))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	temp = 0
	for j in range(k):
		if min(a) < max(b):
			t = a.index(min(a))
			t1 = b.index(max(b))
			temp = a[t]
			a[t] = b[t1]
			b[t1] = temp
	s = 0
	for j in a:
		s += j
	print(s)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	s = 0
	i = 0
	while y != 0 and i < x:
		if a[i] < b[i]:
			y -= 1
			a[i] = b[i]
		i += 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	res = 0
	flag = False
	for i in range(k):
		if a[i] < b[n - i - 1]:
			res += b[n - i - 1]
		else:
			flag = True
			break
	if flag:
		res += sum(a[i:])
	else:
		res += sum(a[k:])
	print(res)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = sorted(map(int, input().split()))
	B = sorted(map(int, input().split()), reverse=True)
	S = sum(A)
	for i in range(k):
		(a, b) = (A[i], B[i])
		if a >= b:
			break
		S -= a
		S += b
	print(S)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	sm = 0
	for i in range(0, k):
		if b[n - i - 1] > a[i]:
			sm += b[n - i - 1]
		else:
			sm += a[i]
	for i in range(k, n):
		sm += a[i]
	print(sm)


from sys import stdin
from collections import Counter, deque
from itertools import product
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if b[-i - 1] > a[i]:
			a[i] = b[-i - 1]
	print(sum(a))


def findLargest(listX, listY, n, k, counterX, counterY):
	listX.sort()
	listY.sort()
	if k == 0:
		return counterX
	for c in range(k):
		if listY[n - 1] > listX[c]:
			counterX -= listX[c]
			counterX += listY[n - 1]
			n -= 1
			if c == k - 1:
				return counterX
		else:
			return counterX
listX = []
listY = []
output = []
counterX = 0
counterY = 0
cases = int(input(''))
for c in range(cases):
	(n, k) = map(int, input().split())
	x = input('').split()
	y = input('').split()
	for c in range(n):
		listX.append(int(x[c]))
		counterX += int(x[c])
		listY.append(int(y[c]))
		counterY += int(y[c])
	z = findLargest(listX, listY, n, k, counterX, counterY)
	output.append(z)
	listX = []
	listY = []
	counterX = 0
	counterY = 0
print(*output, sep='\n')


from sys import stdin, stdout
Pi = lambda x: stdout.write(str(x) + '\n')
Ps = lambda x: stdout.write(str(x))
S = lambda x: x * (x + 1) // 2
I = lambda x: 1 + 2 * x
R = lambda : stdin.readline()
Ri = lambda x: map(int, x.split())
Rs = lambda x: map(str, x.split())
Rf = lambda x: map(float, x.split())
MaxN = int(100000.0) + 5

def main():
	T = int(R())
	for casos in range(T):
		(n, m) = Ri(R())
		A = list(Ri(R()))
		B = list(Ri(R()))
		A.sort()
		B.sort()
		for i in range(m):
			if A[i] >= B[-i - 1]:
				break
			(A[i], B[-i - 1]) = (B[-i - 1], A[i])
		Pi(sum(A))
main()


number_of_cases = int(input())
for i in range(number_of_cases):
	(n, k) = [int(i) for i in input().split()]
	array_a = sorted([int(i) for i in input().split()])
	array_b = sorted([int(i) for i in input().split()])
	for j in range(k):
		if array_b[-(j + 1)] > array_a[j]:
			array_a[j] = array_b[-(j + 1)]
	print(sum(array_a))


t = int(input())
for ts in range(t):
	sum = 0
	n_k = input().split(' ')
	j = 0
	l = int(n_k[0]) - 1
	a = input().split(' ')
	b = input().split(' ')
	a = [int(f) for f in a]
	b = [int(f) for f in b]
	a.sort()
	b.sort()
	for i in range(int(n_k[1])):
		if int(a[j]) < int(b[l]):
			a[j] = int(b[l])
		j = j + 1
		l = l - 1
	for i in range(int(n_k[0])):
		sum = sum + int(a[i])
	print(sum)


t = int(input())
for i in range(t):
	(e1, e2) = input().split()
	n = int(e1)
	k = int(e2)
	a = input().split()
	a = list(map(int, a))
	a.sort()
	b = input().split()
	b = list(map(int, b))
	b.sort(reverse=True)
	sum = 0
	i = 0
	while i < k:
		if b[i] > a[i]:
			sum += b[i]
			i += 1
		else:
			break
	for j in range(i, n):
		sum += a[j]
	print(sum)


def readStr():
	return input()

def readInts():
	return list(map(int, readStr().split(' ')))

def main(n, k, a, b):
	a = sorted(a)
	b = sorted(b)
	s = 0
	for i in range(n):
		ai = a[i]
		bj = b[-i - 1]
		if i < k and bj > ai:
			s += bj
		else:
			s += ai
	return s
(t,) = readInts()
for _ in range(t):
	(n, k) = readInts()
	a = readInts()
	b = readInts()
	s = main(n, k, a, b)
	print(s)


t = int(input())
while t:
	t = t - 1
	str11 = input()
	(n, k) = map(int, str11.split(' '))
	str1 = input()
	list1 = list(map(int, str1.split(' ')))
	str2 = input()
	list2 = list(map(int, str2.split(' ')))
	min1 = min(list1)
	max2 = max(list2)
	while min1 < max2 and k != 0:
		x = list1.index(min1)
		y = list2.index(max2)
		list1[x] = max2
		list2[y] = min1
		min1 = min(list1)
		max2 = max(list2)
		k = k - 1
	print(sum(list1))


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

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

def solve(a, b, n, k):
	if k == 0:
		return sum(a)
	a = sorted(a)
	b = sorted(b)
	t = sorted(a[:k] + b[-k:])
	return sum(a[k:] + t[k:])

def main():
	for _ in range(ri()):
		(n, k) = ria()
		a = ria()
		b = ria()
		print(solve(a, b, n, k))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l1 = []
	l2 = []
	for _ in range(k):
		mn = float('inf')
		x = 0
		y = 0
		for i in range(len(a)):
			if i in l1:
				continue
			elif a[i] < mn:
				mn = a[i]
				x = i
		mx = 0
		for j in range(len(b)):
			if j in l2:
				continue
			elif b[j] > mx:
				mx = b[j]
				y = j
		l1.append(x)
		l2.append(y)
		if a[x] < b[y]:
			(a[x], b[y]) = (b[y], a[x])
	print(sum(a))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	b = b[:k]
	temp = a[:k] + b[:k]
	temp.sort(reverse=True)
	a = temp[:k] + a[k:]
	print(sum(a))


def int_input():
	return int(input())

def ints_input():
	return (int(x) for x in input().split())
t = int_input()
for _ in range(t):
	(n, k) = ints_input()
	a = sorted(ints_input())
	b = list(ints_input())
	ans = sum(a[k:])
	if k:
		ans += sum(sorted((*b, *a[:k]))[-k:])
	print(ans)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	for i in range(y):
		a = max(list2)
		b = min(list1)
		if b < a:
			list1.remove(b)
			list1.append(a)
			list2.remove(a)
	print(sum(list1))


import sys
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

def si():
	return input()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def read():
	tc = 0
	if tc:
		input = sys.stdin.readline
	else:
		sys.stdin = open('input1.txt', 'r')
		sys.stdout = open('output1.txt', 'w')

def solve():
	for _ in range(ii()):
		(n, k) = mi()
		a = li()
		b = li()
		a.sort()
		b.sort()
		s = 0
		i = 0
		j = n - 1
		while k:
			if a[i] >= b[j]:
				break
			else:
				s += b[j]
				j -= 1
				i += 1
			k -= 1
		for i in range(i, n):
			s += a[i]
		print(s)
solve()


t = int(input())
output = []
for _ in range(t):
	(n, k) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	for i in range(k):
		if min(a) < max(b):
			temp = min(a)
			a[a.index(min(a))] = max(b)
			b[b.index(max(b))] = temp
	output.append(sum(a))
for i in output:
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = len(b) - 1
	l = 1
	p = sum(a)
	f = 0
	while l <= k:
		t = a[i]
		a[i] = b[j]
		b[j] = t
		i += 1
		j -= 1
		if p >= sum(a):
			f = 1
			print(p)
			break
		else:
			p = sum(a)
		l += 1
	if f != 1:
		print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = sorted([int(i) for i in input().split()])
	b = sorted([int(p) for p in input().split()])
	l = []
	a.insert(0, 0)
	b.insert(0, 0)
	for v in range(1, k + 1):
		if a[v] < b[-v]:
			a[v] = b[-v]
		else:
			pass
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	p = sorted(a)
	q = sorted(b)
	if min(p) >= max(q):
		print(sum(a))
		continue
	for j in range(k):
		if p[j] < q[n - (j + 1)]:
			p[j] = q[n - (j + 1)]
		else:
			break
	print(sum(p))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		min_a = min(a)
		max_b = max(b)
		if min_a >= max_b:
			break
		index_a = a.index(min_a)
		index_b = b.index(max_b)
		tmp = a[index_a]
		a[index_a] = b[index_b]
		b[index_b] = tmp
	print(sum(a))


T = int(input())
for i in range(1, T + 1):
	(n, k) = [int(i) for i in input().split(' ')]
	A = [int(i) for i in input().split(' ')]
	B = [int(i) for i in input().split(' ')]
	A.sort()
	B.sort(reverse=True)
	result = sum(A)
	for j in range(k):
		if A[j] < B[j]:
			result -= A[j]
			result += B[j]
	print(result)


t = int(input())
ans = []
for i in range(t):
	det = input().split()
	(n, k) = (int(det[0]), int(det[1]))
	a = input().split()
	b = input().split()
	for j in range(n):
		a[j] = int(a[j])
		b[j] = int(b[j])
	a.sort()
	b.sort(reverse=True)
	count = 0
	while k > 0:
		if a[count] < b[count]:
			k -= 1
			a[count] = b[count]
		count += 1
		if count == n:
			break
	sum = 0
	for j in a:
		sum += j
	ans.append(sum)
for i in ans:
	print(i)


t = int(input())
for i in range(t):
	m = [int(i) for i in input().split()]
	n = m[0]
	k = m[1]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	b.reverse()
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))


import math
total_case = int(input())
for i in range(total_case):
	aline = input().split()
	(n, k) = [int(x) for x in aline]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	sa = sorted(a)
	sb = sorted(b, key=lambda x: -x)
	for i in range(k):
		if sb[i] > sa[i]:
			sa[i] = sb[i]
	print(sum(sa))


t = int(input())
w = []
for i in range(t):
	c = 0
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		if min(a) < max(b):
			a.append(max(b))
			b.remove(max(b))
			a.remove(min(a))
			b.append(min(a))
	ss = 0
	for z in a:
		ss = ss + z
	w.append(ss)
for ty in w:
	print(ty)


import sys

def solution():
	t = int(input())
	while t > 0:
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a.sort()
		b.sort()
		i = 0
		while k > 0:
			if b[-1] > a[i]:
				a[i] = b[-1]
				b.pop()
				i += 1
			k -= 1
		print(sum(a))
		t -= 1
solution()


a = int(input())
for _ in range(a):
	(n, k) = map(int, input().split())
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	c.sort(reverse=True)
	sum = 0
	j = 0
	for i in range(k):
		b.append(c[i])
	b.sort(reverse=True)
	for i in range(n):
		sum += b[i]
	print(sum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(a) for a in input().split()]
	b = [int(b) for b in input().split()]
	p = sorted(a)
	q = sorted(b)
	q = q[::-1]
	l = []
	if min(a) >= max(b):
		print(sum(a))
	else:
		for i in range(k):
			if min(p[i:]) >= max(q[i:]):
				pass
			else:
				p[i] = q[i]
		print(sum(p))


t = int(input())
while t != 0:
	t -= 1
	L = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	n = L[0]
	k = L[1]
	while k > 0:
		if min(a) >= max(b):
			break
		min_a = min(a)
		i_a = a.index(min_a)
		max_b = max(b)
		i_b = b.index(max_b)
		temp = min_a
		a[i_a] = max_b
		b[i_b] = temp
		k -= 1
	print(sum(a))


def solve(n, k, arr1, arr2, ans):
	arr1.sort()
	arr2.sort(reverse=True)
	total = 0
	index = 0
	for i in range(n):
		if k == 0:
			break
		if arr1[i] < arr2[i]:
			total += arr2[i]
			index = i + 1
			k -= 1
	total += sum(arr1[index:n])
	ans.append(total)

def main():
	t = int(input())
	ans = []
	for i in range(t):
		(n, k) = map(int, input().split())
		arr1 = list(map(int, input().split()))
		arr2 = list(map(int, input().split()))
		solve(n, k, arr1, arr2, ans)
	for i in ans:
		print(i)
main()


t = int(input())
for j in range(t):
	(n, k) = (int(j) for j in input().split(' '))
	arr_a = [int(j) for j in input().split(' ')]
	arr_b = [int(j) for j in input().split(' ')]
	arr_a.sort()
	arr_b.sort(reverse=True)
	swaps = 0
	for j in range(n):
		if swaps >= k:
			break
		if arr_a[j] <= arr_b[j]:
			(arr_a[j], arr_b[j]) = (arr_b[j], arr_a[j])
			swaps += 1
	print(sum(arr_a))


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	mi = 0
	ma = n - 1
	while k:
		if a[mi] < b[ma]:
			(b[ma], a[mi]) = (a[mi], b[ma])
			mi += 1
			ma -= 1
		else:
			break
		k -= 1
	print(sum(a))


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


def show(a, b, n, k):
	a.sort()
	b.sort()
	for i in range(k):
		if a[k - i - 1] > b[i - k]:
			continue
		else:
			return sum(a[k - i:]) + sum(b[i - k:])
	return sum(a)
n = int(input())
for _ in range(n):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(show(a, b, n, k))


t = int(input())
ans = 0
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for j in range(n):
		if b[j] > a[j] and k > 0:
			temp = b[j]
			b[j] = a[j]
			a[j] = temp
			k -= 1
	ans = sum((k for k in a))
	print(ans)


def arrin():
	n = input()
	n = n.split(' ')
	ans = []
	for i in n:
		ans.append(int(i))
	return ans
t = int(input())
while t > 0:
	t -= 1
	s = input()
	s = s.split(' ')
	n = int(s[0])
	k = int(s[1])
	a = arrin()
	b = arrin()
	c = []
	for i in a:
		c.append([i, 0])
	for i in b:
		c.append([i, 1])
	c.sort(reverse=True, key=lambda i: i[0])
	ans = 0
	ct = 0
	for i in c:
		if ct < n:
			if k > 0 and i[1] == 1:
				ans = ans + i[0]
				ct = ct + 1
				k = k - 1
			elif i[1] == 0:
				ans = ans + i[0]
				ct = ct + 1
	print(ans)


from collections import deque
from collections import Counter
for i in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort(reverse=True)
	l2.sort(reverse=True)
	j = n - 1
	i = 0
	flag = 1
	count = 0
	s = sum(l1)
	while flag:
		if count == k:
			flag = 0
			continue
		if l2[i] > l1[j]:
			s = s + l2[i] - l1[j]
			i += 1
			j -= 1
			count += 1
		else:
			flag = 0
	print(s)


from collections import defaultdict as dd
import math
import sys

def nn():
	return int(input())

def li():
	return list(input())

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

def lm():
	return list(map(int, input().split()))
q = nn()
for _ in range(q):
	(n, k) = mi()
	alist = lm()
	blist = lm()
	alist.sort()
	blist.sort()
	s = sum(alist)
	swaps = 0
	while swaps < k and blist[-swaps - 1] > alist[swaps]:
		s += blist[-swaps - 1] - alist[swaps]
		swaps += 1
	print(s)


N = int(input())
for i in range(N):
	v = list(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	a.sort()
	b.sort()
	i = 0
	m = 0
	j = len(a) - 1
	while i < v[1]:
		if a[i] < b[j]:
			a[i] = b[j]
		i = i + 1
		j = j - 1
	print(sum(a))


from sys import stdin
input = stdin.readline

def solve():
	(a, b) = map(int, input().split())
	lst1 = sorted(list(map(int, input().split())))
	lst2 = sorted(list(map(int, input().split())))[::-1]
	for i in range(b):
		a = lst1[i]
		b = lst2[i]
		lst1[i] = max(a, b)
	print(sum(lst1))
tt = int(input())
for _ in range(tt):
	solve()


numb = int(input())
for n in range(numb):
	word = str(input()).split(' ')
	ele = int(word[0])
	turns = int(word[1])
	arr1 = str(input()).split(' ')
	arr2 = str(input()).split(' ')
	for m in range(ele):
		arr1[m] = int(arr1[m])
		arr2[m] = int(arr2[m])
	x = 0
	while x < ele - 1:
		if arr1[x] > arr1[x + 1]:
			(arr1[x], arr1[x + 1]) = (arr1[x + 1], arr1[x])
			x = 0
		else:
			x += 1
	y = 0
	while y < ele - 1:
		if arr2[y] > arr2[y + 1]:
			(arr2[y], arr2[y + 1]) = (arr2[y + 1], arr2[y])
			y = 0
		else:
			y += 1
	arr2 = arr2[::-1]
	tota = 0
	for z in range(turns):
		if arr2[z] > arr1[z]:
			arr1[z] = arr2[z]
	for h in range(ele):
		tota = tota + arr1[h]
	print(tota)


t = int(input())
while t > 0:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	arr = a[0:k] + b[n - k:n]
	arr.sort()
	na = arr[k:2 * k] + a[k:n]
	ans = sum(na)
	print(ans)
	t = t - 1


def solve(n, k, a, b):
	a = sorted(a, reverse=True)
	b = sorted(b, reverse=True)
	idx_a = 0
	idx_b = 0
	res = 0
	for i in range(n):
		curr_a = a[idx_a]
		curr_b = b[idx_b]
		if curr_b > curr_a and k > 0:
			res += curr_b
			idx_b += 1
			k -= 1
		else:
			res += curr_a
			idx_a += 1
	return res

def main():
	T = int(input())
	for _ in range(T):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		print(solve(n, k, a, b))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	L = list(map(int, input().split()))
	M = list(map(int, input().split()))
	L.sort()
	M.sort()
	for i in range(k):
		if L[i] < M[n - 1 - i]:
			L[i] = M[n - 1 - i]
	print(sum(L))


n = int(input())
for num in range(n):
	t = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sum = 0
	for num in range(t[1]):
		if max(b) > min(a):
			a[a.index(min(a))] = max(b)
			b.remove(max(b))
	for numbers in a:
		sum += numbers
	print(sum)


def main(n, j, a, b):
	(a, b) = (sorted(a), sorted(b, reverse=True))
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
	return sum(a)
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(main(n, k, a, b))


for i in range(int(input())):
	(n, k) = [int(_) for _ in input().split()]
	A = sorted([int(_) for _ in input().split()])
	B = sorted([int(_) for _ in input().split()])
	C = sorted(A[:k] + B[-k:])
	A = A[k:]
	B = B[:-k]
	print(sum(A) + (k > 0) * sum(C[-k:]))


from math import *
from collections import *
from operator import itemgetter
import bisect
i = lambda : input()
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
I = lambda : list(map(int, input().split()))
chrIdx = lambda x: ord(x) - 96
idxChr = lambda x: chr(96 + x)
t = ii()
for _ in range(t):
	(n, k) = iia()
	a = iia()
	b = iia()
	a.sort()
	b.sort()
	x = 0
	ans = sum(a)
	p = 0
	for i in range(0, k):
		if a[i] < b[n - i - 1]:
			ans -= a[i]
			ans += b[n - i - 1]
	print(ans)


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = [int(num) for num in input().split()]
		a = [int(num) for num in input().split()]
		b = [int(num) for num in input().split()]
		a = sorted(a)
		b = sorted(b, reverse=True)
		i = 0
		while i < k and i < n:
			if a[i] < b[i]:
				(a[i], b[i]) = (b[i], a[i])
			i += 1
		print(sum(a))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort(reverse=True)
	for i in range(n):
		if k == 0:
			break
		arr1[i] = max(arr1[i], arr2[i])
		k -= 1
	print(sum(arr1))


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = sorted(list(map(int, input().split())))
		b = sorted(list(map(int, input().split())), reverse=True)
		idx = 0
		while k > 0:
			if b[idx] <= a[idx]:
				break
			(a[idx], b[idx]) = (b[idx], a[idx])
			idx += 1
			k -= 1
		print(sum(a))
main()


t = int(input())
for _ in range(t):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	if k == 0:
		print(sum(a))
		continue
	a.sort()
	b.sort()
	suma = 0
	i = 0
	while i < k and a[0] < b[-1]:
		suma += b.pop(-1)
		a.pop(0)
		i += 1
	suma += sum(a)
	print(suma)


n = int(input())
for i in range(n):
	(k, t) = map(int, input().split())
	arr1 = sorted(list(map(int, input().split())))
	arr2 = sorted(list(map(int, input().split())))
	for i in range(t):
		if arr1[i] < arr2[k - 1 - i]:
			arr1[i] = arr2[k - 1 - i]
	print(sum(arr1))


import sys
t = int(sys.stdin.readline().strip())
res = []
for i in range(t):
	(n, k) = map(int, sys.stdin.readline().strip().split())
	a = list(map(int, sys.stdin.readline().strip().split()))
	b = list(map(int, sys.stdin.readline().strip().split()))
	sa = sorted(a)
	sb = sorted(b, reverse=True)
	for j in range(k):
		for k in range(n):
			if sb[k] > sa[k]:
				sa[k] = sb[k]
				break
	print(sum(sa))


import bisect
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()))
	for i in range(k):
		c = a[0]
		d = b[-1]
		if c < d:
			del a[0]
			del b[-1]
			bisect.insort_left(a, d)
			bisect.insort_left(b, c)
		else:
			break
	print(sum(a))


t = int(input())
for j in range(t):
	ch1 = input()
	L1 = [int(i) for i in ch1.split()]
	n = L1[0]
	k = L1[1]
	cha = input()
	a = [int(i) for i in cha.split()]
	chb = input()
	b = [int(i) for i in chb.split()]
	attempt = 1
	while attempt < k + 1:
		minimuma = min(a)
		ranga = [i for i in range(n) if a[i] == minimuma][0]
		maximumb = max(b)
		rangb = [i for i in range(n) if b[i] == maximumb][0]
		if minimuma >= maximumb:
			attempt = k + 1
		else:
			a[ranga] = maximumb
			b[rangb] = minimuma
			attempt += 1
	print(sum(a))


from bisect import insort

def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
		else:
			break
	print(sum(a))
for _ in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = sorted(a)
	b = sorted(b)
	j = n - 1
	i = 0
	for __ in range(k):
		if b[j] < a[i]:
			break
		r = b[j]
		b[j] = a[i]
		a[i] = r
		j -= 1
		i += 1
	print(sum(a))


t = int(input())
for u in range(t):
	n = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	for i in range(n[1]):
		if a[i] <= b[i]:
			a[i] = b[i]
		else:
			break
	print(sum(a))


count = int(input())
list_of_answer = []
for i in range(0, count):
	line = input()
	list_of_line = line.split()
	list_of_line = list(map(int, list_of_line))
	number_of_changes = list_of_line[1]
	first_line = input()
	list_of_first_line = first_line.split()
	list_of_first_line = list(map(int, list_of_first_line))
	second_line = input()
	list_of_second_line = second_line.split()
	list_of_second_line = list(map(int, list_of_second_line))
	for i in range(0, number_of_changes):
		list_of_first_line.sort()
		list_of_second_line.sort()
		if list_of_second_line[-1] > list_of_first_line[0]:
			(list_of_second_line[-1], list_of_first_line[0]) = (list_of_first_line[0], list_of_second_line[-1])
	list_of_answer.append(sum(list_of_first_line))
for i in list_of_answer:
	print(i)


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	temp = k
	t = 0
	i = len(a) - 1
	j = len(b) - 1
	ans = 0
	for i in range(n):
		if k > 0:
			if a[i] < b[n - 1 - i]:
				a[i] = b[n - 1 - i]
				k -= 1
	print(sum(a))


def minIndex(s):
	min = 0
	i = 1
	while i < len(s):
		if s[min] > s[i]:
			min = i
		i += 1
	return min

def maxIndex(s):
	max = 0
	i = 1
	while i < len(s):
		if s[max] < s[i]:
			max = i
		i += 1
	return max

def listSum(s):
	sum = 0
	for i in s:
		sum += i
	return sum
size = int(input())
(K, A, B) = ([], [], [])
i = 0
while i < size:
	tmp = input()
	K.append(int(tmp.split(' ')[1]))
	tmp = input()
	A.append(list(map(int, tmp.split(' '))))
	tmp = input()
	B.append(list(map(int, tmp.split(' '))))
	i += 1
i = 0
while i < size:
	j = 0
	while j < K[i]:
		if A[i][minIndex(A[i])] >= B[i][maxIndex(B[i])]:
			break
		(A[i][minIndex(A[i])], B[i][maxIndex(B[i])]) = (B[i][maxIndex(B[i])], A[i][minIndex(A[i])])
		j += 1
	print(listSum(A[i]))
	i += 1


def M(n, k, A, B):
	A.sort()
	B.sort(reverse=True)
	for i in range(k):
		if A[i] < B[i]:
			A[i] = B[i]
	return sum(A)
for i in range(int(input())):
	[n, k] = input().split(' ')
	(n, k) = (int(n), int(k))
	A = input().split(' ')
	B = input().split(' ')
	for i in range(n):
		A[i] = int(A[i])
		B[i] = int(B[i])
	print(M(n, k, A, B))


t = int(input())
for ti in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = input().split()
	a = [int(i) for i in a]
	b = input().split()
	b = [int(i) for i in b]
	a.sort()
	b.sort()
	change = 0
	for i in range(k - 1, -1, -1):
		if a[i] < b[n - i - 1]:
			change = 1
			break
	if change == 1:
		print(sum(a[i + 1:]) + sum(b[n - i - 1:]))
	else:
		print(sum(a))


import math
t = int(input())
for __ in range(t):
	h = []
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	h.append(sum(a))
	for i in range(k):
		a[i] = b[i]
		h.append(sum(a))
	print(max(h))


t = int(input())
for _ in range(t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	a_arr = [int(y) for y in input().split()]
	b_arr = [int(y) for y in input().split()]
	a_arr.sort()
	b_arr.sort(reverse=True)
	for i in range(k):
		if a_arr[i] < b_arr[i]:
			a_arr[i] = b_arr[i]
	print(sum(a_arr))


for i in range(0, int(input())):
	(n, k) = [int(f) for f in input().split()]
	a = [int(f) for f in input().split()]
	b = [int(f) for f in input().split()]
	a.sort()
	b.sort()
	b.reverse()
	for i in range(0, k):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))


t = int(input().strip())
for i in range(t):
	[n, k] = list(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	a.sort()
	b.sort()
	sumi = 0
	j = 0
	while j < k and a[j] < b[-j - 1]:
		sumi += b[-j - 1]
		j += 1
	for i in range(j, len(a)):
		sumi += a[i]
	print(sumi)


_IS_DEBUG_MODE = False

def Problem():
	if _IS_DEBUG_MODE == True:
		testcaseList = []
		testcaseList.append([2, 1, [1, 2], [3, 4]])
		testcaseList.append([5, 5, [5, 5, 6, 6, 5], [1, 2, 5, 4, 3]])
		testcaseList.append([5, 3, [1, 2, 3, 4, 5], [10, 9, 10, 10, 9]])
		testcaseList.append([4, 0, [2, 2, 4, 3], [2, 4, 2, 3]])
		testcaseList.append([4, 4, [1, 2, 2, 1], [4, 4, 5, 4]])
	else:
		t = int(input())
		testcaseList = []
		for testcaseIndex in range(t):
			(n, k) = map(int, input().split())
			a = list(map(int, input().split()))
			b = list(map(int, input().split()))
			testcaseList.append([n, k, a, b])
	return testcaseList

def Solver(testcaseList):
	for (n, k, a, b) in testcaseList:
		if _IS_DEBUG_MODE == True:
			print('testcase', n, k, a, b)
		a.sort()
		b.sort()
		j = 0
		for i in range(k):
			if a[i] >= b[-i - 1]:
				break
			else:
				j += 1
		if j == 0:
			answer = sum(a)
		else:
			answer = sum(a[j:]) + sum(b[-j:])
		print(answer)
if _IS_DEBUG_MODE == True:
	import time
	startTime = time.time()
testcaseList = Problem()
Solver(testcaseList)
if _IS_DEBUG_MODE == True:
	endTime = time.time()
	print('time', endTime - startTime)


T = int(input())
for i in range(T):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	count = 0
	a = sorted(a)
	b = sorted(b, reverse=True)
	sum1 = 0
	sum2 = 0
	for j in range(k):
		if a[j] < b[j]:
			sum1 += a[j]
			sum2 += b[j]
	print(sum(a) - sum1 + sum2)


import sys
import math as mt
t = int(input())
for __ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	a.sort()
	j = 0
	cnt = 0
	for i in range(n):
		if a[i] < b[j] and k > 0:
			a[i] = b[j]
			j += 1
			k -= 1
	print(sum(a[:]))


t = int(input())
list1 = []
for test_case in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	sum_a = 0
	if k == 0:
		for number_a in a:
			sum_a += number_a
		list1.append(sum_a)
	else:
		i = 0
		for moves in range(k):
			if a[i] < b[-(i + 1)]:
				a[i] = b[-(i + 1)]
			i += 1
		for number_a in a:
			sum_a += number_a
		list1.append(sum_a)
for items1 in list1:
	print(items1)


for y in range(int(input())):
	(a, b) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	lst1.sort()
	for i in range(b):
		if lst1[i] >= max(lst2):
			break
		else:
			t = lst1[i]
			lst1[i] = max(lst2)
			lst2.remove(max(lst2))
	print(sum(lst1))


def main():
	t = int(input())
	for c in range(t):
		(n, k) = [int(s) for s in input().split(' ')]
		a = [int(s) for s in input().split(' ')]
		b = [int(s) for s in input().split(' ')]
		print(solve(a, b, n, k))

def solve(a, b, n, k):
	a.sort()
	b.sort()
	swap = 0
	i = 0
	while swap < k and i < n:
		if a[i] < b[-i - 1]:
			a[i] = b[-i - 1]
			swap += 1
		i += 1
	return sum(a)
main()


from functools import reduce
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(delimiter=' '):
		return input().split(delimiter)

	@staticmethod
	def list_int(delimiter=' '):
		return list(map(int, input().split(delimiter)))

def main():
	t = Read.int()
	for _ in range(t):
		(n, k) = Read.list_int()
		a = sorted(Read.list_int())
		b = sorted(Read.list_int())
		summ = 0
		i = 0
		j = n - 1
		while i < n and k and (a[i] < b[-i - 1]):
			summ += b[-i - 1]
			i += 1
			k -= 1
		summ += sum(a[i:])
		print(summ)
main()


import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

def main():
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	if a[0] > b[-1]:
		return sum(a)
	ans = 0
	for i in range(n):
		if i < k and a[i] < b[n - 1 - i]:
			ans += b[n - 1 - i]
		else:
			ans += a[i]
	return ans
t = int(input())
for _ in range(t):
	print(main())


t = int(input())
for test in range(t):
	n_k = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	for swaps in range(n_k[1]):
		if b[b.index(max(b))] > a[a.index(min(a))]:
			(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
	print(sum(a))


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	g = b[::-1]
	p = 0
	while p != k:
		if g[p] > a[p]:
			a[p] = g[p]
		p += 1
	print(sum(a))


def solve(a, b, k):
	n = len(a)
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			tmp = a[i]
			a[i] = b[i]
			b[i] = tmp
	print(sum(a))
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(a, b, k)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr2 = sorted(arr2, reverse=True)
	ans = arr1 + arr2[:k]
	ans = sorted(ans, reverse=True)
	print(sum(ans[:n]))


import sys

def inp():
	return sys.stdin.readline().strip()
for _ in range(int(inp())):
	(n, k) = map(int, inp().split())
	a = list(map(int, inp().split()))
	b = list(map(int, inp().split()))
	ans = 0
	a.sort()
	b.sort()
	ans = 0
	while n > 0:
		if b and a[-1] > b[-1]:
			ans += a.pop()
			n -= 1
			continue
		if b and k > 0:
			ans += b.pop()
			k -= 1
			n -= 1
			continue
		ans += a.pop()
		n -= 1
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	n = input()
	n = n.split()
	(n, m) = (n[0], n[1])
	a = input()
	a = a.split()
	(x, y) = ([], [])
	for i in a:
		x.append(int(i))
	b = input()
	b = b.split()
	for i in b:
		y.append(int(i))
	a = sorted(x)
	b = sorted(y, reverse=True)
	res = 0
	for i in range(int(m)):
		if b[i] > a[i]:
			a[i] = b[i]
		res += int(a[i])
	for i in range(int(m), len(a)):
		res += int(a[i])
	print(res)


t = int(input())

def test():
	(a, b) = map(int, input().split())
	q = list(map(int, input().split()))
	x = list(map(int, input().split()))
	for j in range(b):
		mn_i = q.index(min(q))
		mx = max(x)
		if mx > q[mn_i]:
			x[x.index(mx)] = q[mn_i]
			q[mn_i] = mx
	return sum(q)
for i in range(t):
	print(test())


t = int(input())
while t > 0:
	t -= 1
	l = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	n = l[0]
	k = l[1]
	a.sort()
	b.sort()
	fp = 0
	lp = n - 1
	while True:
		if lp < 0 or fp >= n:
			break
		if k > 0 and b[lp] > a[fp]:
			a[fp] = b[lp]
			fp += 1
			lp -= 1
			k -= 1
		else:
			break
	print(sum(a))


t = input()
t = int(t)
while t != 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		max_2 = max(b)
		min_1 = min(a)
		pos_max = b.index(max(b))
		pos_min = a.index(min(a))
		if max_2 > min_1:
			b[pos_max] = a[pos_min]
			a[pos_min] = max_2
		else:
			break
	print(sum(a))
	t += -1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort(reverse=True)
	ans = 0
	index_a = 0
	index_b = 0
	elem = 0
	while elem < k:
		elem += 1
		if a[index_a] > b[index_b]:
			ans += a[index_a]
			index_a += 1
		else:
			ans += b[index_b]
			index_b += 1
			index_a += 1
	while index_a < len(a):
		ans += a[index_a]
		index_a += 1
	print(ans)


import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	cnt = 0
	for i in range(n):
		if cnt == k:
			break
		if a[i] < b[i]:
			a[i] = b[i]
			cnt += 1
	print(sum(a))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	j = 0
	res = 0
	if k == 0:
		print(sum(a))
	else:
		a.sort(reverse=False)
		b.sort(reverse=True)
		for i in range(len(a)):
			if a[i] < b[j] and k > 0:
				res += b[j]
				j += 1
				k -= 1
			elif a[i] >= b[j]:
				res += a[i]
			else:
				res += a[i]
		print(res)
	t -= 1


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	(n, m) = li()
	a = li()
	b = li()
	ans = a + b
	c = Counter(a)
	d = Counter(b)
	ans.sort(reverse=True)
	s = 0
	k = 0
	for i in range(2 * n):
		if ans[i] in c:
			c[ans[i]] -= 1
			if c[ans[i]] == 0:
				del c[ans[i]]
			k += 1
			s += ans[i]
		elif m > 0:
			d[ans[i]] -= 1
			if d[ans[i]] == 0:
				del d[ans[i]]
			m -= 1
			k += 1
			s += ans[i]
		if k == n:
			break
	print(s)
for _ in range(I()):
	solve()


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	s = [int(x) for x in input().split()]
	t = [int(x) for x in input().split()]
	for i in range(k):
		if min(s) >= max(t):
			break
		else:
			s.sort(reverse=False)
			t.sort(reverse=True)
			a = s[0]
			b = t[0]
			s[0] = b
			t[0] = a
	print(sum(s))


t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	list1 = [int(i) for i in input().split()]
	list2 = [int(i) for i in input().split()]
	list1.sort()
	list2.sort()
	if list1[0] >= list2[-1]:
		print(sum(list1))
	else:
		i = 0
		try:
			while k != 0 and list1[i] <= list2[-1]:
				b = list1[i]
				list1[i] = list2[-1]
				list2[-1] = b
				list2.sort()
				k -= 1
				i += 1
		except:
			pass
		print(sum(list1))


t = int(input())
out = []
for i in range(t):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	for i in range(k):
		mini = min(l1)
		maxi = max(l2)
		if maxi > mini:
			l1.insert(l1.index(mini) + 1, maxi)
			l1.remove(mini)
			l2.insert(l2.index(maxi) + 1, mini)
			l2.remove(maxi)
	out.append(sum(l1))
for i in out:
	print(i)


T = int(input())
for t in range(0, T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sortedA = sorted(a, reverse=False)
	sortedB = sorted(b, reverse=True)
	for i in range(0, k):
		sortedA[i] = max(sortedA[i], sortedB[i])
	print(f'{sum(sortedA)}')


t = int(input())
while t > 0:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = sorted(a)
	b = sorted(b, reverse=True)
	sumr = 0
	i = 0
	while k > 0 and i < n:
		if b[i] > a[i]:
			sumr += b[i]
			k -= 1
		else:
			sumr += a[i]
		i += 1
	if i < n:
		sumr += sum(a[i:])
	print(sumr)
	t -= 1


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	mass = [int(x) for x in input().split()]
	arr.sort()
	mass.sort(reverse=True)
	s = sum(arr)
	for i in range(k):
		if arr[i] < mass[i]:
			s += mass[i] - arr[i]
	print(s)


t = int(input())
li = []
for i in range(t):
	s = 0
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for j in range(k):
		if a[j] < b[j]:
			a[j] = b[j]
		else:
			break
	for k in a:
		s += k
	li.append(s)
for i in li:
	print(i)


for _ in range(int(input())):
	s = input().split()
	k = int(s[1])
	a = [int(i) for i in input().split()]
	b = [int(j) for j in input().split()]
	a.sort()
	b.sort()
	c = 0
	for rr in range(k):
		c += max(a[rr], b[-1 - rr])
	c += sum(a[k:])
	print(c)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr.sort()
	arr2.sort(reverse=True)
	for j in range(k):
		if arr[j] < arr2[j]:
			arr[j] = arr2[j]
		else:
			break
	print(sum(arr))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	while k > 0:
		a = sorted(a)
		b = sorted(b)
		a.append(b[-1])
		del b[-1]
		a = sorted(a)
		b = sorted(b)
		b.append(a[0])
		del a[0]
		k -= 1
	print(sum(a))


t = int(input())
s = 0
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	c = a + b
	s = 0
	(maxa, maxb, mina, minb) = (a[n - 1], b[n - 1], a[0], b[0])
	if maxb <= mina:
		print(sum(a))
	else:
		for j in range(n - k):
			s = s + a[n - j - 1]
			c.remove(a[n - j - 1])
		c.sort()
		for j in range(k):
			s = s + c[len(c) - j - 1]
		print(s)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().strip().split(' ')))
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	if min(a) >= max(b):
		print(sum(a))
		continue
	maxi = sum(a)
	for i in range(k):
		a.remove(min(a))
		a.append(max(b))
		b.remove(max(b))
		if sum(a) > maxi:
			maxi = sum(a)
	print(maxi)


n = int(input())
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	d = [int(i) for i in input().split()]
	c = sorted(c)
	d = sorted(d, reverse=True)
	e = 0
	sum = 0
	for j in range(0, len(c)):
		if c[j] < d[j] and e < b:
			e = e + 1
			sum = sum + d[j]
		else:
			sum = sum + c[j]
	print(sum)


t = int(input())
for x in range(t):
	(n, m) = map(int, input().strip().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	a.sort(reverse=True)
	b.sort(reverse=True)
	if m == 0:
		ans = sum(a)
	else:
		for i in range(n - 1, -1, -1):
			if a[i] < b[n - 1 - i]:
				a[i] = b[n - 1 - i]
				c += 1
				if c == m:
					break
	ans = sum(a)
	print(ans)


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[n - i - 1]:
			(a[i], b[n - i - 1]) = (b[n - i - 1], a[i])
	print(sum(a))


for j in range(int(input())):
	(n, k) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[-(i + 1)]:
			a[i] = b[-(i + 1)]
		else:
			break
	print(sum(a))


testCases = int(input())
for _ in range(testCases):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	aIndex = 0
	bIndex = 0
	swaps = 0
	while swaps < k and aIndex < n and (bIndex < n):
		a_ = a[aIndex]
		b_ = b[bIndex]
		if a_ < b_:
			temp = a_
			a[aIndex] = b_
			b[bIndex] = temp
			swaps += 1
			aIndex += 1
			bIndex += 1
		else:
			break
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	ans = 0
	p = 0
	for i in range(n):
		if a[i] < b[i] and p < k:
			(a[i], b[i]) = (b[i], a[i])
			p += 1
	print(sum(a))


import sys
input = sys.stdin.readline
from collections import defaultdict as dd
t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	i = 0
	j = 0
	while i < n and j < n and k:
		if a[i] < b[j]:
			a[i] = b[j]
			i += 1
			j += 1
			k -= 1
		else:
			break
	print(sum(a))
	t -= 1


test_case = int(input())
while test_case:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if k == 0:
		test_case -= 1
		print(sum(a))
		continue
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))
	test_case -= 1


t = int(input())
for s in range(t):
	(n, k) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	for i in range(0, k, 1):
		a1 = min(a)
		a2 = max(b)
		y = a.index(a1)
		z = b.index(a2)
		if a1 < a2:
			temp = a[y]
			a[y] = b[z]
			b[z] = temp
		else:
			break
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, swaps) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = list(reversed(sorted(b)))
	if swaps == 0 or a[0] >= b[0]:
		print(sum(a))
	else:
		i = 0
		while i < swaps:
			if a[i] < b[i]:
				a[i] = b[i]
				i += 1
			else:
				break
		print(sum(a))


def TwoArraysAndSwaps(n, k, a, b):
	a_orden = sorted(a)
	b_orden = sorted(b)[::-1]
	for i in range(k):
		if a_orden[i] < b_orden[i]:
			a_orden[i] = b_orden[i]
	return sum(a_orden)
Lista = []
total = int(input())
for i in range(total * 3):
	All = [int(i) for i in input().split()]
	Lista.append(All)
for j in range(0, len(Lista), 3):
	print(TwoArraysAndSwaps(Lista[j][0], Lista[j][1], Lista[j + 1], Lista[j + 2]))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for move in range(k):
		min_a = min(a)
		min_idx = a.index(min_a)
		max_b = max(b)
		max_idx = b.index(max_b)
		if min_a < max_b:
			(a[min_idx], b[max_idx]) = (b[max_idx], a[min_idx])
	print(sum(a))


from collections import deque
for _ in range(int(input())):
	(arrlen, moves) = map(int, input().split(' '))
	a = deque(sorted(map(int, input().split(' '))))
	b = deque(sorted(map(int, input().split(' '))))
	ansarr = deque()
	res = 0
	prev = -1
	while moves:
		if not b or not a:
			break
		if b[-1] > a[-1]:
			a.popleft()
			ansarr.append(b.pop())
			moves -= 1
		else:
			ansarr.append(a.pop())
	print(sum(a) + sum(ansarr))


t = int(input())
for i in range(t):
	s = input()
	s = s.split(' ')
	n = int(s[0])
	k = int(s[1])
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:n]
	if k == 0:
		print(sum(a))
	elif n == 1:
		if a[0] > b[0]:
			print(sum(a))
		else:
			print(sum(b))
	else:
		for j in range(k):
			if min(a) < max(b):
				flaga = a.index(min(a))
				flagb = b.index(max(b))
				temp = a[flaga]
				a[flaga] = b[flagb]
				b[flagb] = temp
		print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	s = sum(a)
	b = sorted(b, reverse=True)
	ind = 0
	while k and a[ind] < b[ind]:
		s += b[ind] - a[ind]
		k -= 1
		ind += 1
		if k == 0 or ind == n:
			break
	print(s)


for p in range(int(input())):
	(n, k) = map(int, input().split())
	l = [int(num) for num in input().split()]
	m = [int(num) for num in input().split()]
	l.sort()
	m.sort(reverse=True)
	(a, b) = (0, 0)
	for j in range(k):
		if a < n and b < n and (l[a] <= m[b]):
			l[a] = m[b]
			(a, b) = (a + 1, b + 1)
		else:
			break
	print(sum(l))


from sys import stdin, stdout
for query in range(int(stdin.readline())):
	nk = stdin.readline().split()
	n = int(nk[0])
	k = int(nk[1])
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	a = sorted(a)
	b = sorted(b, reverse=True)
	total = sum(a)
	for index in range(n):
		if k > 0 and a[index] < b[index]:
			total += b[index] - a[index]
			k -= 1
		else:
			break
	stdout.write(str(total) + '\n')


t = int(input())
answer = []
for _ in range(t):
	(n, k) = list(map(int, input().split(' ')))
	arr_a = list(map(int, input().split(' ')))
	arr_b = list(map(int, input().split(' ')))
	if k > 0:
		while k > 0:
			min_idx = arr_a.index(min(arr_a))
			max_idx = arr_b.index(max(arr_b))
			if arr_a[min_idx] < arr_b[max_idx]:
				temp = arr_a[min_idx]
				arr_a[min_idx] = arr_b[max_idx]
				arr_b[max_idx] = temp
			k -= 1
	answer.append(sum(arr_a))
for item in answer:
	print(item)


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	x = 0
	y = 0
	p = 0
	while x < k and y < n:
		y = y + 1
		if a[p] < b[n - p - 1]:
			x = x + 1
			z = b[n - p - 1]
			b[n - p - 1] = a[p]
			a[p] = z
			p = p + 1
	print(sum(a))


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l1 = sorted(l1)
	l2 = list(map(int, input().split()))
	l2 = sorted(l2, reverse=True)
	i = 0
	while i < n:
		if s > 0:
			if l2[i] > l1[i]:
				(l2[i], l1[i]) = (l1[i], l2[i])
				s -= 1
		i += 1
	print(sum(l1))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	A = map(int, input().split())
	B = map(int, input().split())
	A = list(A)
	B = list(B)
	for i in range(k):
		c = min(A)
		d = max(B)
		if c >= d:
			break
		else:
			e = A.index(c)
			f = B.index(d)
			A[e] = d
			B[f] = c
	print(sum(A))


testCase = int(input())
for i in range(testCase):
	(n, k) = [int(x) for x in input().split(' ')]
	list_a = [int(x) for x in input().split(' ')]
	list_b = [int(x) for x in input().split(' ')]
	if k == 0:
		print(sum(list_a))
	else:
		list_a.sort()
		for i in range(k):
			if list_a[i] < max(list_b):
				temp = list_a[i]
				index = list_b.index(max(list_b))
				list_a[i] = list_b[index]
				list_b[index] = temp
		print(sum(list_a))


n = int(input())

def swap(x1, x2, x3):
	for j in range(0, x1):
		if l1[l1.index(min(l1))] < l2[l2.index(max(l2))]:
			temp = l1[l1.index(min(l1))]
			l1[l1.index(min(l1))] = l2[l2.index(max(l2))]
			l2[l2.index(max(l2))] = temp
		else:
			pass
	print(sum(l1))
while n:
	(l1, l2) = ([], [])
	(a, b) = input().split(' ')
	(a, b) = (int(a), int(b))
	l1 = input().split(' ')
	l2 = input().split(' ')
	l1 = [int(i) for i in l1]
	l2 = [int(i) for i in l2]
	swap(b, l1, l2)
	n = n - 1


t = int(input())
for k in range(0, t):
	(n, k) = [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)
	d = sorted(b)
	for i in range(0, n):
		for j in range(n - 1, -1, -1):
			if c[i] < d[j] and k > 0:
				temp = c[i]
				c[i] = d[j]
				d[j] = temp
				k -= 1
	print(sum(c))


import math
t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	vetor = []
	soma = 0
	for j in range(n):
		aux1 = max(a)
		aux2 = max(b)
		if aux1 >= aux2:
			vetor.append(aux1)
			soma += aux1
			a.remove(aux1)
		elif m > 0:
			vetor.append(aux2)
			soma += aux2
			b.remove(aux2)
			m -= 1
		else:
			vetor.append(aux1)
			soma += aux1
			a.remove(aux1)
	print(soma)


Test = int(input())
for i in range(Test):
	(a, k) = map(int, input().split(' '))
	array_a = list(map(int, input().split(' ')))
	array_b = list(map(int, input().split(' ')))
	array_a.sort()
	array_b.sort(reverse=True)
	for c in range(0, k):
		if array_a[c] < array_b[c]:
			array_a[c] = array_b[c]
	print(sum(array_a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(_) for _ in input().split()]
	b = [int(_) for _ in input().split()]
	a.sort()
	b.sort(reverse=True)
	ans = []
	b_idx = 0
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[b_idx]
			b_idx += 1
		else:
			pass
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	B.sort()
	A.sort(reverse=True)
	i = n - 1
	while k > 0 and i >= 0:
		if A[i] < B[i]:
			A[i] = B[i]
			i -= 1
			k -= 1
		elif A[i] >= B[i]:
			break
	sum = 0
	for i in A:
		sum += i
	print(sum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(index_a, index_b, min_a, max_b) = (0, 0, 0, 0)
	for i in range(k):
		min_a = min(a)
		for j in range(n):
			if min_a == a[j]:
				index_a = j
		for t in range(n):
			max_b = max(b)
			for s in range(n):
				if max_b == b[s]:
					index_b = s
		if max_b > min_a:
			(a[index_a], b[index_b]) = (b[index_b], a[index_a])
	print(sum(a))


t = int(input())
while t:
	t = t - 1
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a_s = sorted(a)
	b_s = sorted(b)
	answer = 0
	for i in range(n):
		j = n - 1 - i
		addition = b_s[j] - a_s[i]
		answer = answer + a_s[i]
		if k > 0 and addition > 0:
			answer = answer + addition
			k = k - 1
	print(answer)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sum1 = sum(a)
	while k != 0:
		max1 = max(b)
		min1 = min(a)
		a.remove(min1)
		b.remove(max1)
		a.append(max1)
		sum1 = max(sum1, sum(a))
		k = k - 1
	print(sum1)


t = int(input())
for i in range(t):
	nk = tuple(map(int, input().split()))
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	ans = sum(a)
	for j in range(nk[1]):
		if b[j] - a[j] > 0:
			ans += b[j] - a[j]
	print(ans)


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

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

def lsplit():
	return list(map(int, list(input())))
t = int(input())
for _ in range(t):
	(n, k) = mput()
	a = lsput()
	b = lsput()
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[n - 1 - i]:
			c = a[i]
			a[i] = b[n - 1 - i]
			b[n - 1 - i] = c
		else:
			break
	print(sum(a))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l.sort()
	l1.sort()
	l1 = l1[::-1]
	for i in range(m):
		if l[i] < l1[i]:
			l[i] = l1[i]
	print(sum(l))


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if a[i] < b[n - i - 1]:
			a[i] = b[n - i - 1]
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sa = sum(a)
	sb = sum(b)
	if k == 0:
		print(sa)
	else:
		a.sort()
		b.sort(reverse=True)
		for y in range(k):
			if b[y] > a[y]:
				a[y] = b[y]
			else:
				break
		print(sum(a))


t = int(input())
while t:
	nk = input().split()
	k = int(nk[1])
	firstArray = list(map(int, input().split()))
	secondArray = list(map(int, input().split()))
	firstArray.sort()
	secondArray.sort(reverse=True)
	for i in range(k):
		if firstArray[i] < secondArray[i]:
			firstArray[i] = secondArray[i]
	print(sum(firstArray))
	t -= 1


for _ in range(int(input())):
	(n, k) = [*map(int, input().split())]
	a = [*map(int, input().split())]
	b = [*map(int, input().split())]
	b.sort()
	b = b[::-1]
	a.sort()
	ans = 0
	if max(b) <= min(a):
		print(sum(a))
	else:
		for i in range(0, n):
			if k != 0:
				if b[i] > a[i]:
					(b[i], a[i]) = (a[i], b[i])
					k -= 1
		print(sum(a))


for _ in range(int(input())):
	(dlug, swapy) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	if swapy == 0:
		print(sum(a))
		continue
	a.sort()
	b.sort(reverse=True)
	suma = 0
	for x in range(swapy):
		if a[x] > b[x]:
			x -= 1
			break
		suma += b[x]
	suma += sum(a[x + 1:])
	print(suma)


t = int(input())
for _ in range(t):
	(n, k) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	z = sum(a)
	for _ in range(k):
		c = a.copy()
		a[0] = max(b)
		b[0] = min(c)
		a = sorted(a)
		b = sorted(b, reverse=True)
		z = max(z, sum(a))
	print(z)


t = int(input())
answer = []
for c in range(t):
	line = input().split()
	n = int(line[0])
	k = int(line[1])
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	best = 0
	sum = 0
	for j in a:
		sum += j
	if sum > best:
		best = sum
	for i in range(k):
		temp = b[n - i - 1]
		b[n - i - 1] = a[i]
		a[i] = temp
		sum = 0
		for j in a:
			sum += j
		if sum > best:
			best = sum
	answer.append(best)
for l in answer:
	print(str(l))


def max_a_sum(n, k, a, b):
	a = sorted(a)
	b = sorted(b)
	max_sum = 0
	for i in range(k, n):
		max_sum += a[i]
	c = sorted(a[:k] + b[n - k:])
	for i in range(k, 2 * k):
		max_sum += c[i]
	return max_sum
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(max_a_sum(n, k, a, b))


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	count = 0
	z = 0
	p = max(b)
	q = min(a)
	if p < q:
		z = 1
	while count < k and z == 0:
		p = max(b)
		q = min(a)
		if p <= q:
			z = 1
		if q < p:
			t = b.index(p)
			s = a.index(q)
			a[s] = p
			b[t] = q
			count += 1
	print(sum(a))


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		(n, k) = map(int, input().split())
		aa = [int(a) for a in input().split()]
		bb = [int(a) for a in input().split()]
		res = sum(aa)
		aa.sort()
		bb.sort(reverse=True)
		for i in range(k):
			if bb[i] <= aa[i]:
				break
			res += bb[i] - aa[i]
		print(res)
	q = int(input())
	for _ in range(q):
		solve()
main()


def functionB(arra, arrb, n, k):
	newArray = []
	arra.sort()
	arrb.sort(reverse=True)
	newArray += arra[k:n]
	arra = arra[0:k]
	arra.sort(reverse=True)
	i = 0
	while len(newArray) < n:
		if arrb[0] > arra[i]:
			newArray.append(arrb[0])
			del arrb[0]
		else:
			newArray.append(arra[i])
			i += 1
	print(sum(newArray))
a = int(input())
for _ in range(a):
	(n, k) = map(int, input().split())
	arra = [int(i) for i in input().split()]
	arrb = [int(i) for i in input().split()]
	functionB(arra, arrb, n, k)


t = int(input())
for r in range(t):
	(m, n) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2 = sorted(l2, reverse=True)
	s = 0
	for i in range(len(l1)):
		if i < n and l2[i] > l1[i]:
			s = s + l2[i]
		else:
			s = s + l1[i]
	print(s)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	t1 = list(map(int, input().split()))
	t2 = list(map(int, input().split()))
	t = []
	for i in t1:
		t.append((i, 1))
	for i in t2:
		t.append((i, 2))
	s = []
	for i in sorted(t, reverse=True):
		if i[1] == 1:
			s.append(i[0])
		elif k > 0:
			s.append(i[0])
			k -= 1
		if len(s) == n:
			break
	print(sum(s))


import sys
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	b.reverse()
	ans = 0
	for i in range(n):
		if i < k:
			ans += max(a[i], b[i])
		else:
			ans += a[i]
	print(ans)


T = int(input())
I = 0
while I < T:
	s = input().split()
	n = int(s[0])
	k = int(s[1])
	a = input().split()
	a = [int(c) for c in a]
	b = input().split()
	b = [int(c) for c in b]
	t = 0
	while t < k:
		l = a.index(min(a))
		y = b.index(max(b))
		if a[l] < b[y]:
			p = a[l]
			a[l] = b[y]
			b[y] = p
		t += 1
	print(sum(a))
	I += 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arra = map(int, input().split())
	arrb = map(int, input().split())
	arra = sorted(arra)
	arrb = sorted(arrb, reverse=True)
	for i in range(k):
		if arrb[i] < arra[i]:
			break
		(arra[i], arrb[i]) = (arrb[i], arra[i])
	print(sum(arra))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	for i in range(n):
		if i >= k or a[i] > b[i]:
			break
		elif a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))
	t = t - 1


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, k) = list(map(int, stdin.readline().split()))
	a = sorted(map(int, stdin.readline().split()))
	b = sorted(map(int, stdin.readline().split()), reverse=True)
	sm = sum(a)
	for i in range(k):
		if b[i] > a[i]:
			sm = sm - a[i] + b[i]
	print(sm)


def main():
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	b = sorted(list(map(int, input().split())), reverse=True)
	for i in b:
		if i > a[-1] and k > 0:
			k -= 1
			a[-1] = i
			a = sorted(a, reverse=True)
		if k == 0:
			break
	sm = 0
	for i in a:
		sm += i
	print(sm)
t = int(input())
for i in range(t):
	main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort(reverse=True)
	i = 0
	while i < n and arr1[i] < arr2[i] and (k > 0):
		arr1[i] = arr2[i]
		k -= 1
		i += 1
	print(sum(arr1))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l1.sort()
	l2.sort()
	l2.reverse()
	i = 0
	while i < n and k > 0:
		if l1[i] < l2[i]:
			l1[i] = l2[i]
			k -= 1
		i += 1
	print(sum(l1))


t = int(input())
for i in range(t):
	res = 0
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for j in range(k):
		a.append(max(b))
		a.remove(min(a))
		b.remove(max(b))
	for x in a:
		res += x
	print(res)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, k) = sp()
	a = l()
	b = l()
	a.sort()
	b.sort(reverse=True)
	answer = 0
	i = 0
	while i < n and k > 0:
		if a[i] < b[i]:
			a[i] = b[i]
			i += 1
			k -= 1
		else:
			break
	out(sum(a))


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	dv = 0
	rv = 0
	for i in range(k):
		if B[n - i - 1] > A[i]:
			dv = dv + B[n - i - 1]
			rv = rv + 1
		else:
			break
	for i in range(n - rv):
		dv = dv + A[n - i - 1]
	print(dv)


t = int(input())
arr = []
for j in range(t):
	n = input()
	(n, k) = n.split()
	(n, k) = (int(n), int(k))
	p = input()
	q = input()
	a = sorted(list(map(int, p.split())))
	b = sorted(list(map(int, q.split())), reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
	sum = 0
	for i in a:
		sum += i
	arr.append(sum)
for i in arr:
	print(i)


from collections import *
import sys

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

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	(n, k) = rl()
	a = rl()
	b = rl()
	a.sort()
	b.sort(reverse=True)
	b = deque(b)
	for i in range(k):
		if a[i] < b[0]:
			a[i] = b.popleft()
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	a.sort()
	b.sort()
	c = k
	s = 0
	for i in range(n):
		if a[i] < b[n - 1 - i] and c:
			s += b[n - 1 - i]
			c -= 1
		else:
			s += a[i]
	print(s)


n = int(input())
test_cases = [[input().split() for _ in range(3)] for _ in range(n)]

def str_to_lst(lst_):
	return [int(x) for x in lst_]
for (h, a, b) in test_cases:
	(a, b) = [str_to_lst(x) for x in [a, b]]
	k = int(h[-1])
	while k > 0:
		a.sort()
		b.sort()
		if b[-1] > a[0]:
			(a[0], b[-1]) = (b[-1], a[0])
		k -= 1
	print(sum(a))


a = n = int(input())
for i in range(n):
	d = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	for j in range(d[1]):
		if max(b) > min(a):
			a.append(max(b))
			b.remove(max(b))
			b.append(min(a))
			a.remove(min(a))
	c = 0
	for j in range(d[0]):
		c = c + a[j]
	print(c)


t = int(input())
for i in range(t):
	(n1, k1) = input().split(' ')
	n = int(n1)
	k = int(k1)
	arr1 = input().split(' ')
	brr1 = input().split(' ')
	arr = brr = []
	for i in range(n):
		arr = arr + [int(arr1[i])]
		brr = brr + [int(brr1[i])]
	arr.sort()
	brr.sort()
	i = s = 0
	while arr[min(i, n - 1)] < brr[n - i - 1] and i < k:
		arr[i] = brr[n - i - 1]
		i = i + 1
	for i in range(n):
		s = s + arr[i]
	print(s)


import collections as cc
I = lambda : list(map(int, input().split()))
import sys
input = sys.stdin.readline
for tc in range(int(input())):
	(n, k) = I()
	a = I()
	b = I()
	a.sort()
	b.sort()
	b = b[::-1]
	i = 0
	while k and i < n:
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
			k -= 1
		i += 1
	print(sum(a))


t = int(input())
for _ in range(t):
	inp = list(map(int, input().split()))
	n = inp[0]
	k = inp[1]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ind = 0
	for i in range(len(a)):
		if ind >= k:
			break
		if a[i] < b[len(b) - 1 - i]:
			a[i] = b[len(b) - 1 - i]
			ind += 1
		else:
			break
	print(sum(a))


from sys import stdin
tc = int(stdin.readline())
for _ in range(tc):
	(n, k) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	for _ in range(k):
		min_a = min(a)
		max_b = max(b)
		if min_a < max_b:
			ia = a.index(min_a)
			ib = b.index(max_b)
			(a[ia], b[ib]) = (b[ib], a[ia])
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		if k == 0:
			break
		else:
			mb = max(b)
			ma = min(a)
			if mb > ma:
				a.append(mb)
				a.remove(ma)
				b.append(ma)
				b.remove(mb)
			k -= 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	sum = 0
	i = 0
	j = n - 1
	c = 0
	while k != 0:
		if l2[j] > l1[i]:
			sum = sum + l2[j]
			j = j - 1
			i = i + 1
			c = c + 1
		elif l2[j] < l1[i]:
			break
		k = k - 1
	for i in range(c, n):
		sum = sum + l1[i]
	print(sum)


def inpint():
	return int(input())

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

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

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

def inpstr():
	return list(input())

def main():
	t = inpint()
	for _ in range(t):
		(n, k) = inpimap()
		a = sorted(inpilist())
		b = sorted(inpilist(), reverse=True)
		for i in range(n):
			if i == k:
				break
			if a[i] < b[i]:
				(a[i], b[i]) = (b[i], a[i])
			else:
				break
		print(sum(a))
main()


t = int(input())
anss = [0] * t
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for j in range(k):
		a[j] = max(b[j], a[j])
	anss[i] = sum(a)
for ans in anss:
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ind = 0
	while ind < k and b[ind] > a[ind]:
		ind += 1
	print(sum(a[ind:]) + sum(b[:ind]))


t = int(input())

def array_swaps(n, k, a, b):
	ans = 0
	a = sorted(a)
	b = sorted(b)
	aptr = 0
	bptr = n - 1
	if a[aptr] > b[bptr]:
		return sum(a)
	while k:
		if a[aptr] >= b[bptr]:
			return sum(a)
		else:
			(a[aptr], b[bptr]) = (b[bptr], a[aptr])
			aptr += 1
			bptr -= 1
		k -= 1
	return sum(a)
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ans = array_swaps(n, k, a, b)
	print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	if a[0] >= b[n - 1]:
		print(sum(a))
	else:
		count = 0
		while a[0] < b[n - 1] and count < m:
			temp = a[0]
			a[0] = b[n - 1]
			b[n - 1] = temp
			a.sort()
			b.sort()
			count = count + 1
		print(sum(a))


t = int(input())
for i in range(t):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort(reverse=True)
	count = 0
	for i in range(K):
		if A[i] < B[i]:
			A[i] = B[i]
	print(sum(A))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	j = 0
	for i in range(m):
		if l2[n - i - 1] > l1[j]:
			(l1[j], l2[n - i - 1]) = (l2[n - i - 1], l1[j])
			j += 1
	print(sum(l1))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	max_a = sum(a)
	j = 0
	while k > 0:
		a[j] = b[len(b) - j - 1]
		j += 1
		k -= 1
		if sum(a) > max_a:
			max_a = sum(a)
	print(max_a)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	lst1 = sorted(list(map(int, input().split())))
	lst2 = sorted(list(map(int, input().split())))
	if k == 0:
		print(sum(lst1))
	elif len(lst1) == 1:
		print(max(sum(lst1), sum(lst2)))
	else:
		for i in range(k):
			a = lst1[i]
			b = lst2[-(i + 1)]
			if b > a:
				lst1[i] = b
				lst2[-(i + 1)] = a
		print(sum(lst1))


for jj in range(int(input())):
	(m, l) = map(int, input().split())
	s = list(map(int, input().split()))
	n = list(map(int, input().split()))
	s.sort()
	d = 0
	n.sort(reverse=True)
	for i in range(l):
		if n[i] > s[i]:
			s[i] = n[i]
		else:
			break
	print(sum(s))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	(c, d) = (sum(a), sum(b))
	(p, q) = (c, d)
	for i in range(k):
		p = max(p - a[i] + b[-i - 1], p)
	for i in range(k):
		q = max(q - b[i] + a[-i - 1], q)
	print(p)


def maxsum(a, b, k):
	a = sorted(a, reverse=True)
	b = sorted(b)
	added = 0
	for i in range(k):
		if a[-1] >= b[-1]:
			break
		a.pop()
		added += b.pop()
	return sum(a) + added
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	print(maxsum(a, b, k))


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, k) = [int(x) for x in inp().split()]
	a = [int(x) for x in inp().split()]
	b = [int(x) for x in inp().split()]
	a.sort()
	b.sort()
	total = sum(a)
	for i in range(k):
		if a[i] > b[-1 - i]:
			break
		total -= a[i]
		total += b[-1 - i]
	print(total)


import sys

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

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

def input():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(n, k) = get_ints()
	A = get_array()
	B = get_array()
	A.sort()
	B.sort()
	if A[0] >= B[-1]:
		print(sum(A))
		continue
	while k:
		if A[0] < B[-1]:
			(A[0], B[-1]) = (B[-1], A[0])
			A.sort()
			B.sort()
		k -= 1
	print(sum(A))


t = input()
t = int(t)
while t > 0:
	string = input()
	s = string.split(' ')
	n = int(s[0])
	m = int(s[1])
	x = input()
	x = x.split(' ')
	x = [int(x[i]) for i in range(len(x))]
	y = input()
	y = y.split(' ')
	y = [int(y[i]) for i in range(len(y))]
	x.sort()
	y.sort(reverse=True)
	sum = 0
	for ele in x:
		sum = ele + sum
	for i in range(0, m):
		if x[i] < y[i]:
			sum = sum - x[i] + y[i]
		else:
			break
	print(sum)
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	res = sum(a)
	cur = 0
	used = 0
	if k == 0:
		print(res)
		continue
	for ele in a:
		if b[cur] <= ele:
			break
		res += b[cur] - ele
		used += 1
		cur += 1
		if used == k:
			break
	print(res)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ans = 0
	for i in range(n):
		ans += max(a[i], b[i]) if i < m else a[i]
	print(ans)


import math

def merge(left, right):
	if len(left) == 0:
		return right
	if len(right) == 0:
		return left
	(i, j) = (0, 0)
	result = list()
	while i < len(left) and j < len(right):
		if left[i] <= right[j]:
			result.append(left[i])
			i += 1
		else:
			result.append(right[j])
			j += 1
	if i == len(left):
		result += right[j:]
	if j == len(right):
		result += left[i:]
	return result

def mergesort(a):
	if len(a) <= 1:
		return a
	else:
		mid = len(a) // 2
		left = a[:mid]
		right = a[mid:]
		return merge(mergesort(left), mergesort(right))

def function(a, b, k, n):
	(a, b) = (mergesort(a), mergesort(b))
	(i, j) = (0, n - 1)
	if b[j] < a[i]:
		return sum(a)
	for z in range(k):
		if b[j] > a[i]:
			a[i] = b[j]
			j -= 1
		i += 1
	return sum(a)
t = int(input())
for t in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(function(a, b, k, n))


import sys
from math import sqrt, floor, factorial, gcd
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def a():
	ans = ''
	for _ in range(int(inp())):
		(n, m) = read()
		if n == 1:
			ans += '0\n'
		elif n == 2:
			ans += str(m) + '\n'
		else:
			ans += str(2 * m) + '\n'
	print(ans)

def b():
	ans = ''
	for _ in range(int(inp())):
		(n, k) = read()
		a = sorted(read())
		b = sorted(read(), reverse=True)
		s = 0
		for i in range(k):
			s += max(a[i], b[i])
		s += sum(a[k:])
		ans += str(s) + '\n'
	print(ans)
b()


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	lst1 = list((int(num) for num in input().split()))[:n]
	lst2 = list((int(num) for num in input().split()))[:n]
	lst1 = sorted(lst1)
	lst2 = sorted(lst2)
	if min(lst1) >= max(lst2):
		print(sum(lst1))
	else:
		for j in range(0, k):
			if lst1[j] < lst2[n - j - 1]:
				lst1[j] = lst2[n - j - 1]
		print(sum(lst1))


t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	d = 0
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for j in range(n):
		if d == k:
			break
		if a[j] < b[len(b) - j - 1]:
			(a[j], b[len(b) - j - 1]) = (b[len(b) - j - 1], a[j])
			d += 1
	print(sum(a))
	a.clear()
	b.clear()


n = int(input())
c = list()
a = list()
b = list()
for j in range(n):
	c.append(list(map(int, input().split())))
	a.append(list(map(int, input().split())))
	b.append(list(map(int, input().split())))
for j in range(n):
	x = c[j][0]
	k = c[j][1]
	a1 = sorted(a[j])
	b1 = sorted(b[j])[::-1]
	count = 0
	while count < k:
		if max(b1) <= min(a1):
			count = count + k
		elif min(a1) < max(b1):
			temp = max(b1)
			b1[b1.index(max(b1))] = a1[a1.index(min(a1))]
			a1[a1.index(min(a1))] = temp
			count += 1
	print(sum(a1))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(x) for x in input().split()])
	b = b[::-1]
	j = 0
	while k > 0:
		if a[j] < b[j]:
			a[j] = b[j]
		k -= 1
		j += 1
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	for i in range(k):
		c = min(a)
		d = max(b)
		if c >= d:
			break
		else:
			a.remove(c)
			a.append(d)
			b.remove(d)
	sum = 0
	for i in range(n):
		sum += a[i]
	print(sum)


n = int(input())
for i in range(3 * n):
	z = input().split()
	z = [int(x) for x in z]
	if i % 3 == 0:
		(n, k) = list(z)
	if i % 3 == 1:
		a = list(z)
	if i % 3 == 2:
		b = list(z)
		a.sort()
		b.sort()
		for j in range(k):
			if b[-j - 1] > a[j]:
				a[j] = b[-j - 1]
		print(sum(a))


def swap(a, b, k):
	while k > 0:
		if min(a) < max(b):
			(a[a.index(min(a))], b[b.index(max(b))]) = (max(b), min(a))
			k -= 1
		else:
			break
	return sum(a)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	out = swap(a, b, k)
	print(out)


import math
t = int(input())
for u in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(sorted(list(map(int, input().split()))))
	b = list(sorted(list(map(int, input().split()))))
	for i in range(k):
		if a[i] < b[n - i - 1]:
			(a[i], b[n - i - 1]) = (b[n - i - 1], a[i])
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	i = 0
	j = 0
	while a[i] < b[j] and k > 0:
		a[i] = b[j]
		i += 1
		j += 1
		k -= 1
		if i >= n or j >= n:
			break
	print(sum(a))


import sys

def solve():
	return None

def main():
	q = []
	for line in sys.stdin.readlines():
		q.append(line)
	for i in range(len(q)):
		q[i] = q[i].rstrip().split(' ')
		q[i] = [int(x) for x in q[i]]
	for i in range(1, len(q), 3):
		n = q[i][0]
		k = q[i][1]
		a = q[i + 1]
		b = q[i + 2]
		b.sort(reverse=True)
		a.sort(reverse=True)
		starta = len(a) - 1
		startb = 0
		while k != 0 and a[starta] < b[startb]:
			a[starta] = b[startb]
			starta -= 1
			startb += 1
			k -= 1
		print(sum(a))
main()


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
tc = int(input())
for zzz in range(tc):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr.sort()
	brr.sort()
	crr = brr[-1::-1]
	mar = [False] * n
	for i in range(n):
		if k == 0:
			break
		for j in range(n):
			if arr[i] < crr[j] and mar[j] == False:
				arr[i] = crr[j]
				mar[j] = True
				k -= 1
				break
	print(sum(arr))


for i in range(int(input())):
	(_, mov) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(mov):
		(b[b.index(max(b))], a[a.index(min(a))]) = sorted([b[b.index(max(b))], a[a.index(min(a))]])
	print(sum(a))


nbTests = int(input())
for iTest in range(nbTests):
	somme = 0
	phrase = input().split(' ')
	n = int(phrase[0])
	k = int(phrase[1])
	premier = [0] * n
	deuxieme = [0] * n
	phrase = input().split(' ')
	for i in range(n):
		premier[i] = int(phrase[i])
	phrase = input().split(' ')
	for i in range(n):
		deuxieme[i] = int(phrase[i])
	premier.sort()
	deuxieme.sort()
	pointeur = 0
	while pointeur < k and premier[pointeur] <= deuxieme[n - pointeur - 1]:
		premier[pointeur] = deuxieme[n - pointeur - 1]
		pointeur += 1
	for i in range(n):
		somme += premier[i]
	print(somme)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	first_list = sorted(list(map(int, input().split())))
	second_list = sorted(list(map(int, input().split())))[::-1]
	if k > 0:
		answer = 0
		for j in range(k):
			if first_list[j] < second_list[j]:
				answer += second_list[j]
			else:
				j -= 1
				break
		answer += sum(first_list[j + 1:])
	else:
		answer = sum(first_list)
	print(answer)


t = int(input())
for _ in range(t):
	(n, k) = input().split(' ')
	(n, k) = (int(n), int(k))
	atmp = input().split(' ')
	a = []
	btmp = input().split(' ')
	b = []
	for _ in range(n):
		a.append(int(atmp.pop()))
		b.append(int(btmp.pop()))
	for _ in range(k):
		least = a.index(min(a))
		most = b.index(max(b))
		if a[least] < b[most]:
			(a[least], b[most]) = (b[most], a[least])
	print(sum(a))


import heapq
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = [-1 * int(char) for char in input().split()]
	s = sum(arr1)
	heapq.heapify(arr1)
	heapq.heapify(arr2)
	for _ in range(k):
		a1 = heapq.heappop(arr1)
		a2 = -1 * heapq.heappop(arr2)
		if a2 > a1:
			s -= a1
			s += a2
	print(s)


import math
import os
import random
import re
import sys
t = int(input())
for _ in range(t):
	nk = list(map(int, input().split()))
	n = nk[0]
	k = nk[1]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
	print(sum(a))


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	total = 0
	for i in range(n):
		if i < k:
			total = total + max(a[i], b[i])
		else:
			total = total + a[i]
	print(total)
	t = t - 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	L1 = list(map(int, input().split()))
	L2 = list(map(int, input().split()))
	L1.sort()
	L2.sort(reverse=True)
	ans = 0
	for j in range(k):
		ans += max(L1[j], L2[j])
	ans += sum(L1[k:n])
	print(ans)


t = int(input())
R = lambda : map(int, input().split())
for i in range(t):
	(n, k) = R()
	a = sorted(list(R()))
	b = sorted(list(R()), reverse=True)
	i = 0
	while k > 0:
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
			i += 1
			k -= 1
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = [int(i) for i in input().split()]
	y = [int(i) for i in input().split()]
	x.sort()
	y.sort(reverse=True)
	c = 0
	i = 0
	j = 0
	while c < k and i < len(x) and (j < len(y)):
		if x[i] < y[j]:
			(x[i], y[j]) = (y[j], x[i])
			i = i + 1
			j = j + 1
			c = c + 1
		else:
			j = j + 1
	print(sum(x))


n = int(input())
i = 0
while i < n:
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = sum(a)
	z = 0
	while z < y:
		d = ans - min(a) + max(b)
		if max(ans, d) == ans:
			break
		else:
			ans = max(ans, d)
			a.pop(a.index(min(a)))
			b.pop(b.index(max(b)))
		z = z + 1
	print(ans)
	i = i + 1


t = int(input())
for i in range(t):
	(n, k) = [int(c) for c in input().split(' ')]
	a = [int(c) for c in input().split(' ')]
	b = [int(c) for c in input().split(' ')]
	b = sorted(b, reverse=True)
	combo = sorted(a + b[:k], reverse=True)[:n]
	print(sum(combo))


for _ in range(int(input())):
	(n, k, A) = (*map(int, input().split()), 0)
	(a, b) = (sorted(map(int, input().split())), sorted(map(int, input().split()), reverse=True))
	for i in range(n):
		A += (a[i], b[i])[k and a[i] < b[i]]
		k = max(k - (a[i] < b[i]), 0)
	print(A)


num = int(input())
lst = []
for i in range(num):
	(x, y) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	for j in range(y):
		if max(lst2) <= min(lst1):
			break
		else:
			lst2.append(min(lst1))
			lst1.remove(min(lst1))
			lst1.append(max(lst2))
			lst2.remove(max(lst2))
	lst.append(sum(lst1))
for var in lst:
	print(var)


from sys import stdin, stdout
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		min_idx = a.index(min(a))
		max_idx = b.index(max(b))
		if a[min_idx] < b[max_idx]:
			(a[min_idx], b[max_idx]) = (b[max_idx], a[min_idx])
		else:
			break
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = [int(n) for n in input().split()]
	arr = list(map(int, input().strip().split()))[:n]
	brr = list(map(int, input().strip().split()))[:n]
	arr.sort()
	brr.sort()
	i = 0
	while k and i < n:
		if arr[i] >= brr[n - i - 1]:
			break
		else:
			arr[i] = brr[n - i - 1]
			i = i + 1
			k = k - 1
	summ = 0
	for i in range(n):
		summ = summ + arr[i]
	print(summ)


a = int(input())
for i in range(a):
	(b, c) = map(int, input().split())
	l = list(map(int, input().split()))
	m = list(map(int, input().split()))
	m.sort(reverse=True)
	l += m[:c]
	l.sort(reverse=True)
	print(sum(l[:b]))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	for i in range(k):
		l2 = list2.index(max(list2))
		l1 = list1.index(min(list1))
		if list1[l1] < list2[l2]:
			temp = list1[l1]
			list1[l1] = list2[l2]
			list2[l2] = temp
		else:
			pass
	print(sum(list1))


t = int(input())
for rep in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	c = 0
	i = n - 1
	j = 0
	while i >= 0 and c < k:
		if b[-1] > a[i]:
			temp = a[j]
			a[j] = b[-1]
			b[-1] = temp
			c += 1
			j += 1
			b.sort()
		else:
			i -= 1
	print(sum(a))


class Heap:

	def __init__(self):
		self.heap = []
		self.heapsize = 0

	def __str__(self):
		return ''.join([i + ' ' for i in self.heap])

	def parent(self, i):
		return (i - 1) // 2

	def leftchild(self, i):
		return i * 2 + 1

	def rightchild(self, i):
		return i * 2 + 2

	def getMin(self):
		return self.heap[0]

	def insertMax(self, key):
		if self.heapsize < len(self.heap):
			self.heap[self.heapsize] = key
			i = self.heapsize
		else:
			self.heap.append(key)
			i = len(self.heap) - 1
			self.heapsize = len(self.heap)
		while i != 0 and self.heap[self.parent(i)] < self.heap[i]:
			(self.heap[self.parent(i)], self.heap[i]) = (self.heap[i], self.heap[self.parent(i)])
			i = self.parent(i)

	def insertMin(self, key):
		if self.heapsize < len(self.heap):
			self.heap[self.heapsize] = key
			i = self.heapsize
			self.heapsize += 1
		else:
			self.heap.append(key)
			i = len(self.heap) - 1
			self.heapsize = len(self.heap)
		while i != 0 and self.heap[self.parent(i)] > self.heap[i]:
			(self.heap[self.parent(i)], self.heap[i]) = (self.heap[i], self.heap[self.parent(i)])
			i = self.parent(i)

	def extractMax(self):
		if self.heapsize <= 0:
			return 'Overflow'
		if self.heapsize == 1:
			self.heapsize -= 1
			return self.heap[0]
		res = self.heap[0]
		self.heap[0] = self.heap[self.heapsize - 1]
		self.heapsize -= 1
		self.maxHeapify(0)
		return res

	def extractMin(self):
		if self.heapsize <= 0:
			return 'Underflow'
		if self.heapsize == 1:
			self.heapsize -= 1
			return self.heap[0]
		res = self.heap[0]
		self.heap[0] = self.heap[self.heapsize - 1]
		self.heapsize -= 1
		self.minHeapify(0)
		return res

	def maxHeapify(self, index):
		l = self.leftchild(index)
		r = self.rightchild(index)
		tempLargest = index
		if l < self.heapsize and self.heap[l] > self.heap[index]:
			tempLargest = l
		if r < self.heapsize and self.heap[r] > self.heap[tempLargest]:
			tempLargest = r
		if tempLargest != index:
			(self.heap[tempLargest], self.heap[index]) = (self.heap[index], self.heap[tempLargest])
			self.maxHeapify(tempLargest)

	def minHeapify(self, index):
		l = self.leftchild(index)
		r = self.rightchild(index)
		tempSmallest = index
		if l < self.heapsize and self.heap[l] < self.heap[index]:
			tempSmallest = l
		if r < self.heapsize and self.heap[r] < self.heap[tempSmallest]:
			tempSmallest = r
		if tempSmallest != index:
			(self.heap[index], self.heap[tempSmallest]) = (self.heap[tempSmallest], self.heap[index])
			self.minHeapify(tempSmallest)
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	h1 = Heap()
	h2 = Heap()
	for i in l1:
		h1.insertMin(i)
	for i in l2:
		h2.insertMax(i)
	i = 0
	while i < k:
		a = h1.extractMin()
		b = h2.extractMax()
		if b > a:
			h1.insertMin(b)
			h2.insertMax(a)
		else:
			h1.insertMin(a)
			h2.insertMax(b)
			break
		i += 1
	summ = 0
	while h1.heapsize > 0:
		summ = summ + h1.extractMin()
	print(summ)


import sys
import math
from collections import Counter, defaultdict
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass

def takeInput():
	return [int(x) for x in input().strip().split()]
t = int(input())
while t != 0:
	t -= 1
	(n, k) = takeInput()
	a = takeInput()
	b = takeInput()
	a = sorted(a)
	b = sorted(b, reverse=True)
	i = 0
	j = 0
	swaps = 0
	while i < n and j < n and (swaps < k):
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			swaps += 1
			i += 1
			j += 1
		else:
			break
	print(sum(a))


def process(k, a, b):
	a.sort()
	b.sort(reverse=True)
	for i in range(int(k)):
		if a[0] < b[0]:
			a.remove(a[0])
			a.append(b[0])
			b.remove(b[0])
		else:
			break
	sum = 0
	for ele in a:
		sum += ele
	print(sum)
t = int(input())
for _ in range(t):
	(n, k) = input().split()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	process(k, a, b)


nb_cases = int(input())
while nb_cases > 0:
	nb_cases -= 1
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for x in range(k):
		if max(b) > min(a):
			a.remove(min(a))
			a.append(max(b))
			b.remove(max(b))
		else:
			break
	print(sum(a))


from functools import lru_cache

def solve(aa, bb, k):
	aa = sorted(aa)
	bb = sorted(bb)[::-1]
	res = [max(a, b) for (a, b) in zip(aa[:k], bb[:k])]
	res += aa[k:]
	return sum(res)
for _ in range(int(input())):
	(_, k) = list(map(int, input().split()))
	aa = list(map(int, input().split()))
	bb = list(map(int, input().split()))
	print(solve(aa, bb, k))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = []
	A.sort()
	B.sort(reverse=True)
	C.extend(A[:k])
	C.extend(B[:k])
	C.sort(reverse=True)
	ans = sum(C[:k]) + sum(A[k:])
	print(ans)


t = int(input())
for _ in range(0, t):
	(n, k) = map(int, input().split())
	aa = sorted([int(i) for i in input().split()])
	bb = sorted([int(i) for i in input().split()])[::-1]
	ss = sum(aa)
	for i in range(0, k):
		if bb[i] > aa[i]:
			ss -= aa[i]
			ss += bb[i]
	print(ss)


t = int(input())
for _ in range(t):
	(n, k) = tuple([int(i) for i in input().split()])
	alist = [int(i) for i in input().split()]
	blist = [int(i) for i in input().split()]
	alist.sort()
	blist.sort()
	[alist.append(i) for i in blist[n - k:]]
	alist.sort()
	print(sum(alist[-n:]))


t = input()
t = int(t)
while t > 0:
	a = list()
	b = list()
	temp = 0
	sums = 0
	line = input()
	p = line.split()
	x = int(p[0])
	y = int(p[1])
	line = input()
	p = line.split()
	for i in p:
		i = int(i)
		a.append(i)
	line = input()
	p = line.split()
	for i in p:
		i = int(i)
		b.append(i)
	a = sorted(a)
	b = sorted(b, reverse=True)
	for i in range(y):
		if b[i] > a[i]:
			sums = sums + b[i]
			temp = temp + 1
		else:
			break
	for j in range(temp, x):
		sums = sums + a[j]
	t = t - 1
	print(sums)


from heapq import *
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(lambda x: -x, map(int, input().split())))
	heapify(a)
	heapify(b)
	for i in range(k):
		if a[0] < -b[0]:
			olda = heappop(a)
			oldb = -heappop(b)
			heappush(a, oldb)
			heappush(b, -olda)
		else:
			break
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if k == 0:
		print(sum(a))
	elif k == 1:
		m = max(b)
		n = min(a)
		s = sum(a)
		if m > n:
			s += m - n
		print(s)
	else:
		a.sort()
		b.sort()
		i = 0
		j = n - 1
		while k and i < n and (j >= 0):
			if b[j] > a[i]:
				(b[j], a[i]) = (a[i], b[j])
				k -= 1
				j -= 1
			i += 1
		print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort()
	idx1 = 0
	idx2 = -1
	for j in range(k):
		if arr1[idx1] < arr2[idx2]:
			(arr1[idx1], arr2[idx2]) = (arr2[idx2], arr1[idx1])
			idx1 += 1
			idx2 -= 1
		else:
			break
	print(sum(arr1))


from fractions import Fraction
import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

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

def iinput():
	return int(input())

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

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
for _ in range(iinput()):
	(n, k) = rinput()
	a = sorted(rlinput(), reverse=True)
	b = sorted(rlinput(), reverse=True)
	ans = 0
	i = 0
	j = 0
	final = 0
	last = -1
	while k > 0 and j < n and (i < n) and (final < n):
		if a[i] >= b[j]:
			ans += a[i]
			i += 1
		else:
			k -= 1
			ans += b[j]
			j += 1
		final += 1
	while final < n and i < n:
		ans += a[i]
		final += 1
		i += 1
	print(ans)


def solve(a, b, n, k):
	a.sort()
	b.sort(reverse=True)
	i = 0
	ans = 0
	while i != n:
		if i < k:
			if b[i] > a[i]:
				ans += b[i]
				i += 1
				continue
			else:
				ans += a[i]
				i += 1
				continue
		ans += a[i]
		i += 1
	print(ans)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(a, b, n, k)


def fcnt():
	result = ''
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a.sort()
		b.sort(reverse=True)
		for i in range(k):
			if a[i] < b[i]:
				a[i] = b[i]
		result += str(sum(a)) + '\n'
	print(result[:-1])
fcnt()


a = int(input())
for i in range(a):
	s = input().split()
	n = int(s[0])
	k = int(s[1])
	a = list(input().split())
	b = list(input().split())
	for j in range(len(a)):
		a[j] = int(a[j])
	for j in range(len(b)):
		b[j] = int(b[j])
	a.sort()
	b.sort()
	f = n - k
	d = []
	for h in range(k):
		if a[h] < b[n - h - 1]:
			d.append(b[n - h - 1])
			a[h] = b[n - h - 1]
	s = 0
	for d in range(n):
		s += a[d]
	print(s)


m = int(input())
j = int()
for i in range(m):
	(a, b) = input().split(' ')
	e = int(a) - int(b)
	s = 0
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	c = sorted(x)
	d = sorted(y)
	for j in range(int(b)):
		if c[j] < d[-j - 1]:
			c[j] = d[-j - 1]
	for k in c:
		s = s + k
	print(s)


def soln(a, b, k):

	def findmin(arr):
		result = 0
		for i in range(len(arr)):
			if arr[i] < arr[result]:
				result = i
		return (result, arr[result])

	def findmax(arr):
		(j, maxb) = findmin([-x for x in arr])
		maxb = -maxb
		return (j, maxb)
	for _ in range(k):
		(i, mina) = findmin(a)
		(j, maxb) = findmax(b)
		if mina >= maxb:
			break
		(a[i], b[j]) = (b[j], a[i])
	return sum(a)

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = [int(x) for x in input().split(' ')]
		a = [int(x) for x in input().split(' ')]
		b = [int(x) for x in input().split(' ')]
		result = soln(a, b, k)
		print(result)
main()


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


t = int(input(''))
c = []
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	count = 0
	while True:
		if min(a) >= max(b) or count == k:
			break
		(a[count], b[n - count - 1]) = (b[n - count - 1], a[count])
		count += 1
	c.append(sum(a))
for i in range(t):
	print(c[i])


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().strip().split()))
	list1 = list(map(int, input().strip().split()))
	list2 = list(map(int, input().strip().split()))
	list1.sort()
	list2.sort()
	list2.reverse()
	ans = sum(list1)
	for i in range(k):
		a = list1[i]
		b = list2[i]
		if a < b:
			ans += b - a
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	ai = 0
	bi = n - 1
	if a[ai] >= b[bi]:
		print(sum(a))
	else:
		x = 1
		while ai < n and bi >= 0 and (a[ai] <= b[bi]) and (x <= k):
			a[ai] = b[bi]
			ai += 1
			bi -= 1
			x += 1
		print(sum(a))


def main():
	ans = []
	for i in range(int(input())):
		(size, swaps) = map(int, input().split())
		a = [int(i) for i in input().split()]
		b = [int(i) for i in input().split()]
		for i in range(swaps):
			if min(a) < max(b):
				(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
		ans.append(sum(a))
	print('\n'.join((str(i) for i in ans)))
main()


import sys
input = sys.stdin.buffer.readline

def print(val):
	sys.stdout.write(str(val) + '\n')
for _ in range(int(input().strip())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
		else:
			break
	print(sum(a))


num_tests = int(input())
for _ in range(num_tests):
	line1 = list(map(int, input().split(' ')))
	(n, k) = (line1[0], line1[1])
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a = sorted(a)
	b = sorted(b, reverse=True)
	a_pointer = 0
	b_pointer = 0
	swaps = 0
	while b_pointer < len(b) and swaps < k:
		if a[a_pointer] < b[b_pointer]:
			(a[a_pointer], b[b_pointer]) = (b[b_pointer], a[a_pointer])
			a_pointer += 1
			b_pointer += 1
			swaps += 1
		else:
			break
	print(sum(a))


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(n, k) = iia()
	a1 = sorted(iia())
	b1 = sorted(iia(), reverse=True)
	for i in range(n):
		if k == 0:
			break
		if a1[i] < b1[i]:
			k -= 1
			a1[i] = b1[i]
	print(sum(a1))


for __ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = 0
	a.sort()
	b.sort()
	for i in range(n):
		if k > 0:
			if a[i] <= b[n - i - 1]:
				a[i] = b[n - i - 1]
				k -= 1
		if k <= 0:
			break
	for i in range(n):
		s += a[i]
	print(s)


t = int(input())
for val in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	sumA = sum(a)
	for vall in range(k):
		if a[vall] < b[vall]:
			sumA = sumA - a[vall] + b[vall]
		else:
			break
	print(sumA)


t = int(input())
for tt in range(t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	a = input().split()
	b = input().split()
	for i in range(n):
		a[i] = int(a[i])
		b[i] = int(b[i])
	a.sort()
	b.sort(reverse=True)
	tmpa = a[:k]
	tmpb = b[:k]
	tmpnew = tmpa + tmpb
	tmpnew.sort(reverse=True)
	print(sum(tmpnew[:k] + a[k:]))


def get():
	out = sum(a)
	na = n - 1
	nb = 0
	while nb < k and a[na] < b[nb]:
		out -= a[na]
		out += b[nb]
		na -= 1
		nb += 1
	return out
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	b = sorted(map(int, input().split()), reverse=True)
	print(get())


import sys
input = sys.stdin.readline

def solve(n, k, a, b):
	ii = 0
	jj = 0
	while k > 0 and ii < n and (jj < n):
		if b[jj] > a[ii]:
			(a[ii], b[jj]) = (b[jj], a[ii])
			k -= 1
			ii += 1
			jj += 1
		else:
			break
	return sum(a)
t = int(input())
for _ in range(t):
	[n, k] = map(int, input().split())
	a = map(int, input().split())
	b = map(int, input().split())
	print(solve(n, k, sorted(a), sorted(b, reverse=True)))


n = int(input())
for i in range(0, n):
	p = input().rstrip().split(' ')
	q = input().rstrip().split(' ')
	r = input().rstrip().split(' ')
	q.sort(key=int)
	r.sort(key=int, reverse=True)
	M = 0
	for j in range(0, int(p[1])):
		if M < len(q):
			if int(q[M]) < int(r[M]):
				q[M] = r[M]
				M += 1
			else:
				break
	W = 0
	for j in range(0, len(q)):
		W += int(q[j])
	print(W)


t = int(input())
results = []
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = sorted(a)
	b = sorted(b)
	curr_sum = sum(a)
	for i in range(k):
		if a[i] > b[-i - 1]:
			break
		curr_sum = curr_sum - a[i] + b[-i - 1]
	results.append(curr_sum)
for item in results:
	print(item)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		x1 = min(a)
		y1 = max(b)
		if x1 >= y1:
			break
		else:
			a.append(y1)
			a.remove(x1)
			b.remove(y1)
	print(sum(a))


k = int(input())
for i in range(k):
	n = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort()
	z = []
	while a[-1] < b[-1] and n[1]:
		n[1] -= 1
		a.pop()
		z.append(b.pop())
		if not a:
			break
	print(sum(a) + sum(z))


import sys

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

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

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

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

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, K) = MAP()
	A = LIST()
	B = LIST()
	A.sort()
	B.sort(reverse=1)
	for i in range(K):
		if A[i] < B[i]:
			(A[i], B[i]) = (B[i], A[i])
	ans = sum(A)
	print(ans)


t = int(input())

def replace(list1, list2):
	index1 = list1.index(min(list1))
	index2 = list2.index(max(list2))
	(list1[index1], list2[index2]) = (list2[index2], list1[index1])
	return (list1, list2)

def swap(k, a, b):
	Sum = sum(a)
	for i in range(k):
		(a, b) = replace(a, b)
		if sum(a) > Sum:
			Sum = sum(a)
			continue
	return Sum
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	result = swap(k, a, b)
	print(result)


def swaps(a, b, k):
	big = sum(a)
	if k == 0 or max(b) <= min(a):
		return big
	for i in range(k):
		tmp_big = max(b)
		tmp_smol = min(a)
		(a[a.index(tmp_smol)], b[b.index(tmp_big)]) = (b[b.index(tmp_big)], a[a.index(tmp_smol)])
		tmp_sum = sum(a)
		if tmp_sum < big:
			return big
		else:
			big = tmp_sum
	return big
t = int(input())
for i in range(t):
	x = list(map(int, input().rstrip().split()))
	k = x[1]
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	print(swaps(a, b, k))


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	a_idx = 0
	b_idx = len(b) - 1
	while k > 0 and a_idx <= len(a) - 1 and (b_idx >= 0) and (a[a_idx] < b[b_idx]):
		a[a_idx] = b[b_idx]
		a_idx += 1
		b_idx -= 1
		k -= 1
	print(sum(a))


for i in range(int(input())):
	(n, k) = (int(j) for j in input().split())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	for j in range(k):
		(mn, mx) = (0, 0)
		for x in range(n):
			if a[x] < a[mn]:
				mn = x
			if b[x] > b[mx]:
				mx = x
		if b[mx] <= a[mn]:
			break
		c = b[mx]
		d = a[mn]
		(a[mn], b[mx]) = (c, d)
	print(sum(a))


t = int(input())
l = []
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	while i < k:
		if a[i] < b[-(i + 1)]:
			(a[i], b[-(i + 1)]) = (b[-(i + 1)], a[i])
		i += 1
	l.append(sum(a))
for i in l:
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if k == 0:
		sa = sum(a)
		sb = sum(b)
		print(sa)
		continue
	a.sort()
	xa = sum(a)
	b = sorted(b, reverse=True)
	arr = a
	for i in range(n):
		if b[i] > a[i]:
			arr[i] = b[i]
			k -= 1
		if k <= 0:
			break
	print(max(sum(arr), xa))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort()
	arr2.reverse()
	i = 0
	while k != 0:
		if arr1[i] < arr2[i]:
			arr1[i] = arr2[i]
			k -= 1
			i += 1
		else:
			i += 1
			k -= 1
			continue
	print(sum(arr1))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while max(b) > min(a) and k > 0:
		k -= 1
		i = a.index(min(a))
		j = b.index(max(b))
		(a[i], b[j]) = (b[j], a[i])
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(1, k + 1):
		k1 = n - i
		if a[i - 1] < b[k1]:
			a[i - 1] = b[k1]
	k2 = sum(a)
	print(k2)


t = int(input())

def fn():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	l = n - k
	r = k
	sum1 = 0
	sum2 = 0
	for i in range(l):
		sum1 += a[i]
	for i in range(r):
		sum2 += b[i]
	maxi = sum1 + sum2
	while l < n:
		sum1 += a[l]
		r -= 1
		sum2 -= b[r]
		l += 1
		maxi = max(sum1 + sum2, maxi)
	print(maxi)
while t:
	t -= 1
	fn()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	arrA = list(map(int, input().split()))
	arrB = list(map(int, input().split()))
	arrA.sort()
	arrB.sort(reverse=True)
	for i in range(k):
		if arrA[i] < arrB[i]:
			f = arrA[i]
			arrA[i] = arrB[i]
	print(sum(arrA))


t = int(input())
a = []
b = []
i = 1
while i <= t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		a_min = min(a)
		b_max = max(b)
		a_min_index = a.index(a_min)
		b_max_index = b.index(b_max)
		if a_min < b_max:
			temp = a[a_min_index]
			a[a_min_index] = b[b_max_index]
			b[b_max_index] = temp
	print(sum(a))
	i += 1


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	(sum, d) = (0, 0)
	for j in range(len(a)):
		if d < k and b[d] > a[j]:
			sum += b[j]
			d += 1
		else:
			sum += a[j]
	print(sum)


t = int(input())
for i in range(t):
	(n, k) = input().split()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	l = []
	c = 0
	j = 0
	for i in range(len(a)):
		if a[i] < b[j] and c < int(k):
			l.append(b[j])
			c = c + 1
			j = j + 1
		else:
			l.append(a[i])
	print(sum(l))


tcs = int(input())
for tc in range(tcs):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	for i in range(k):
		if b[-(i + 1)] > a[i]:
			a[i] = b[-(i + 1)]
	print(sum(a))


import sys
input = sys.stdin.readline

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

def readint():
	return int(input())

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

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

def main():
	t = readint()
	nkab = []
	for _ in range(t):
		nk = list(readnums())
		a = list(readnums())
		b = list(readnums())
		nkab.append([nk, a, b])
	for (nk, a, b) in nkab:
		for k in range(nk[1]):
			if min(a) >= max(b):
				break
			else:
				i = a.index(min(a))
				j = b.index(max(b))
				(a[i], b[j]) = (b[j], a[i])
		print(sum(a))
main()


def solve(aa, bb, k):
	aa.sort()
	bb.sort(reverse=True)
	i = -1
	while i < k - 1:
		if aa[i + 1] < bb[i + 1]:
			i += 1
		else:
			break
	if i == -1:
		return sum(aa)
	else:
		return sum(aa) - sum(aa[:i + 1]) + sum(bb[:i + 1])
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	aa = list(map(int, input().split()))
	bb = list(map(int, input().split()))
	print(solve(aa, bb, k))


def swap(a, b):
	m = max(b)
	mm = min(a)
	md = b.index(m)
	mmd = a.index(mm)
	if m > mm:
		a[mmd] = m
		b[md] = mm
for x in range(int(input())):
	li = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for x in range(li[1]):
		swap(a, b)
	print(sum(a))


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	a = [int(r) for r in input().split()]
	b = [int(r) for r in input().split()]
	a.sort()
	b.sort()
	c = 1
	while max(b) > min(a) and c <= k:
		(a[0], b[len(b) - 1]) = (b[len(b) - 1], a[0])
		a.sort()
		b.sort()
		c += 1
	print(sum(a))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		f = a.index(min(a))
		s = b.index(max(b))
		if a[f] < b[s]:
			(a[f], b[s]) = (b[s], a[f])
		else:
			break
	print(sum(a))


def solve(arr, brr, n, k):
	arr.sort()
	brr.sort(reverse=True)
	i = 0
	sum1 = 0
	while i < n and arr[i] < brr[i] and (k > 0):
		sum1 += brr[i]
		i += 1
		k -= 1
	while i < n:
		sum1 += arr[i]
		i += 1
	print(sum1)
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	solve(arr, brr, n, m)


ex = int(input())
for i in range(ex):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a = sorted(a)
	b = sorted(b)
	len_a = len(a)
	len_b = len(b)
	for j in range(k):
		if b[len_b - 1 - j] > a[j]:
			a[j] = b[len_b - 1 - j]
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	lol = [int(n) for n in input().split()]
	l = [int(n) for n in input().split()]
	for i in range(k):
		lol.sort()
		l.sort(reverse=True)
		if l[0] > lol[0]:
			(lol[0], l[0]) = (l[0], lol[0])
	print(sum(lol))


T = int(input())
while T > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	count = 0
	for i in range(k):
		if a[i] >= b[i]:
			count += a[i]
		else:
			count += b[i]
	for i in range(k, len(a)):
		count += a[i]
	print(count)
	T -= 1


from collections import deque
from collections import OrderedDict
import math
import sys
import os
from io import BytesIO
import threading
import bisect
import heapq
input = sys.stdin.readline
for t in range(int(input())):
	(n, k) = map(int, input().split())
	arA = list(map(int, input().split()))
	arB = list(map(int, input().split()))
	arA.sort()
	arB.sort()
	arB.reverse()
	for i in range(k):
		if arA[i] < arB[i]:
			(arA[i], arB[i]) = (arB[i], arA[i])
		else:
			break
	answer = 0
	for i in range(n):
		answer += arA[i]
	print(answer)


for t in range(int(input())):
	(n, k) = [int(j) for j in input().split()]
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	a.sort()
	k = min(n, k)
	b.sort(reverse=True)
	ct = 0
	i = 0
	j = 0
	sw = 0
	while ct < n and sw < k:
		ct += 1
		if a[i] > b[j]:
			break
		else:
			sw += 1
			i += 1
			j += 1
	print(sum(a[i:]) + sum(b[:i]))


from sys import stdin, stdout
for _ in range(int(input())):
	(n, k) = map(int, stdin.readline().split())
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	a.sort()
	b.sort(reverse=True)
	for i in range(0, k):
		if a[i] >= b[i]:
			break
		else:
			(a[i], b[i]) = (b[i], a[i])
	print(sum(a))


x = int(input())
for i in range(x):
	c = list(map(int, input().strip().split(' ')))
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	a.sort(reverse=True)
	b.sort(reverse=True)
	n = c[0]
	for i in range(c[1]):
		if a[n - 1 - i] <= b[i]:
			a[n - 1 - i] = b[i]
	print(sum(a))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	d = list()
	b.sort(reverse=True)
	sum1 = 0
	c = 0
	i = 0
	for i in range(0, len(a)):
		if m > 0 and a[i] < b[i]:
			c = i
			sum1 = sum1 + b[i]
			m = m - 1
		else:
			sum1 = sum1 + a[i]
	print(sum1)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ai = list(map(int, input().split()))
	bi = list(map(int, input().split()))
	ai.sort()
	bi.sort()
	for i in range(k):
		if ai[i] >= bi[n - i - 1]:
			break
		ai[i] = bi[n - i - 1]
	print(sum(ai))


import sys
import heapq
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(N, K) = [int(x) for x in input().split()]
		A = [int(x) for x in input().split()]
		B = [int(x) for x in input().split()]
		ha = []
		hb = []
		for i in range(N):
			heapq.heappush(ha, A[i])
			heapq.heappush(hb, -B[i])
		while K > 0:
			a = heapq.heappop(ha)
			b = -heapq.heappop(hb)
			if b <= a:
				heapq.heappush(ha, a)
				heapq.heappush(hb, -b)
				break
			heapq.heappush(ha, b)
			heapq.heappush(hb, -a)
			K -= 1
		print(sum(ha))
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	val = sum(a)
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		a[i] = b[i]
		val1 = sum(a)
		if val < val1:
			val = val1
	print(val)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	temp = []
	a.sort()
	b.sort()
	s = 0
	for i in range(1, k + 1):
		s = s + max(a[i - 1], b[-i])
	d = n - k
	for i in range(1, d + 1):
		s = s + a[-i]
	print(s)


import heapq
t = int(input())
for test in range(t):
	arr = input().split()
	(n, k) = (int(arr[0]), int(arr[1]))
	a = input().split()
	b = input().split()
	ha = []
	hb = []
	for i in range(len(a)):
		heapq.heappush(ha, int(a[i]))
		heapq.heappush(hb, -int(b[i]))
	m = sum(ha)
	while k:
		m = max(m, m + (-heapq.heappop(ha) - heapq.heappop(hb)))
		k -= 1
	print(m)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	for j in range(k):
		if A[j] < B[n - j - 1]:
			A[j] = B[n - j - 1]
	print(sum(A))


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = list(a + b)
	s.sort(reverse=True)
	out = 0
	for j in range(k):
		maxB = max(b)
		minA = min(a)
		if maxB > minA:
			a.remove(minA)
			a.append(maxB)
			b.remove(maxB)
	print(sum(a))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	lst1.sort()
	lst2.sort(reverse=True)
	for i in range(b):
		if lst2[i] > lst1[i]:
			lst1[i] = lst2[i]
		else:
			break
	print(sum(lst1))


test = int(input())
for _ in range(test):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	var = 0
	for i in range(n):
		var += a[i]
	for i in range(k):
		if b[n - i - 1] > a[i]:
			var += b[n - i - 1] - a[i]
	print(var)


T = int(input())
while T > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	(i, j) = (0, n - 1)
	res = sum(a)
	for x in range(k):
		if b[j] > a[i]:
			res -= a[i]
			res += b[j]
			j -= 1
			i += 1
		else:
			break
	print(res)
	T -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	counter = 0
	for i in range(n):
		if a[i] <= b[n - i - 1] and counter < k:
			a[i] = b[n - i - 1]
			counter += 1
		else:
			break
	print(sum(a))


for i in range(int(input())):
	line = input().split()
	(n, m) = (int(line[0]), int(line[1]))
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	ans = 0
	for i in range(n):
		if i < m and a[i] < b[i]:
			ans += b[i]
		else:
			ans += a[i]
	print(ans)


import sys
import heapq
import math
import bisect

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

def iinput():
	return int(input())

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

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

def srlinput(fl=False):
	return sorted(list(map(int, input().split())), reverse=fl)

def main():
	(n, k) = rinput()
	q = srlinput(True)
	w = srlinput()
	i = 0
	while i < k and q[-1] < w[-1]:
		i += 1
		(q[-1], w[-1]) = (w[-1], q[-1])
		q = sorted(q, reverse=True)
		w = sorted(w)
	print(sum(q))
for sdfghjkl in range(iinput()):
	main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k:
		s1 = min(a)
		s2 = max(b)
		for i in range(n):
			if a[i] == s1 and s1 < s2:
				temp = a[i]
				a[i] = s2
				b[b.index(s2)] = temp
				break
		k = k - 1
	print(sum(a))


def solve_test_case(t):
	(n, k) = parse_array(int)
	a = parse_array(int)
	b = parse_array(int)
	a.sort(reverse=True)
	b.sort(reverse=True)
	c = a + b[:k]
	c.sort(reverse=True)
	d = c[:n]
	print(sum(d))

def parse_array(f):
	return list(map(f, input().split()))

def solve():
	T = int(input())
	for t in range(T):
		solve_test_case(t)
solve()


import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

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
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

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

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

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

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

def string_list():
	return list(input())

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

def binaryToDecimal(n):
	return int(n, 2)

def solve():
	(n, k) = num_input()
	a = list_input()
	b = list_input()
	if k == 0:
		print(sum(a))
	else:
		a.sort()
		b.sort(reverse=True)
		summ = 0
		for i in range(n):
			if k != 0:
				if b[i] > a[i]:
					summ += b[i]
					k -= 1
				else:
					summ += a[i]
			else:
				summ += a[i]
		print(summ)
t = int(input())
for _ in range(t):
	solve()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(k):
		if min(a) < max(b):
			y = a.index(min(a))
			z = b.index(max(b))
			(a[y], b[z]) = (b[z], a[y])
		else:
			break
	print(sum(a))


t = int(input())
ans = []
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sumVar = 0
	j = 0
	a.sort(reverse=True)
	b.sort(reverse=True)
	while j < n:
		if b[0] > a[0] and k > 0:
			sumVar += b[0]
			k -= 1
			b.pop(0)
		else:
			sumVar += a[0]
			a.pop(0)
		j += 1
	ans.append(sumVar)
for i in range(t):
	print(ans[i])


import sys

def main(a, b, k):
	a.sort()
	b.sort()
	b.reverse()
	i = 0
	j = 0
	while j < k and i < len(b):
		if b[i] > a[i]:
			(a[i], b[i]) = (b[i], a[i])
			j += 1
		i += 1
	return sum(a)
t = sys.stdin.readline()
for i in range(int(t)):
	l1 = list(sys.stdin.readline().rstrip('\n').split(' '))
	k = int(l1[1])
	l2 = list(sys.stdin.readline().rstrip('\n').split(' '))
	a = list(map(int, l2))
	l3 = list(sys.stdin.readline().rstrip('\n').split(' '))
	b = list(map(int, l3))
	print(main(a, b, k))


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()))
	f = 0
	while m != 0 and f == 0:
		a.sort()
		b.sort()
		if a[0] >= b[-1]:
			f = 1
		else:
			x = a[0]
			a[0] = b[-1]
			b[-1] = x
			m = m - 1
	print(sum(a))


t = int(input())
for hh in range(0, t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	su = sum(a)
	for i in range(0, k):
		if a[i] < b[n - 1 - i]:
			su -= a[i]
			su += b[n - 1 - i]
	print(su)


t = int(input())
for i in range(t):
	sum = 0
	x = 0
	y = 0
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a, reverse=True)
	b = sorted(b, reverse=True)
	for j in range(n):
		if a[x] >= b[y] or y >= k:
			sum += a[x]
			x += 1
		else:
			sum += b[y]
			y += 1
	for z in range(x, n - y):
		sum += a[z]
	print(sum)


x = int(input())
for i in range(x):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(m):
		if max(b) < min(a):
			break
		else:
			c1 = a.index(min(a))
			c2 = b.index(max(b))
			a[c1] = max(b)
			b[c2] = min(a)
	print(sum(a))


t = int(input())
for i in range(t):
	n_k = input()
	(n, k) = (int(n_k.split(' ')[0]), int(n_k.split(' ')[1]))
	a = [int(e) for e in input().split(' ')]
	b = [int(e) for e in input().split(' ')]
	a = sorted(a)
	b = sorted(b, reverse=True)
	ans = 0
	k_itr = 0
	for i in range(n):
		if a[i] < b[i] and k_itr < k:
			ans += b[i]
			k_itr += 1
		else:
			ans += a[i]
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	s = sum(a)
	tot = s
	su = s
	for i in range(k):
		maxx = max(b)
		minn = min(a)
		su = su - minn + maxx
		if su > tot:
			tot = su
			a.remove(minn)
			b.remove(maxx)
	print(tot)


a = int(input())
for i in range(0, a):
	x = input().split()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	ind1 = 0
	ind2 = 0
	suum = 0
	j = 0
	moves = 1
	while j < int(x[0]):
		if moves <= int(x[1]):
			if a[ind1] > b[ind2]:
				j = j + 1
				suum = suum + a[ind1]
				ind1 = ind1 + 1
			else:
				j = j + 1
				suum = suum + b[ind2]
				ind2 = ind2 + 1
				ind1 = ind1 + 1
				moves += 1
		else:
			j = j + 1
			suum = suum + a[ind1]
			ind1 = ind1 + 1
	print(suum)


c = int(input())
for z in range(c):
	a = [int(i) for i in input().split(' ')]
	l = [int(i) for i in input().split(' ')]
	k = [int(i) for i in input().split(' ')]
	l.sort()
	k.sort(reverse=True)
	for i in range(a[1]):
		if l[i] < k[i]:
			l[i] = k[i]
	print(sum(l))


def swap(i, j):
	g = a[i]
	r = b[j]
	a[i] = r
	b[j] = g
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	mna = min(a)
	mxb = max(b)
	i = a.index(mna)
	j = b.index(mxb)
	c = 0
	while mna < mxb and c < k:
		swap(i, j)
		c += 1
		mna = min(a)
		mxb = max(b)
		i = a.index(mna)
		j = b.index(mxb)
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr_a = [int(x) for x in input().split()]
	arr_b = [int(x) for x in input().split()]
	arr_a = sorted(arr_a)
	arr_b = sorted(arr_b, reverse=True)
	for i in range(k):
		if arr_a[i] < arr_b[i]:
			arr_a[i] = arr_b[i]
	sum1 = 0
	for i in range(n):
		sum1 += arr_a[i]
	print(sum1)


for _ in range(int(input())):
	n = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	suma = sum(a)
	sumb = sum(b)
	for k in range(n[1]):
		i = a.index(min(a))
		j = b.index(max(b))
		if b[j] > a[i]:
			x = a[i]
			a[i] = b[j]
			b[j] = x
	print(sum(a))


t = int(input())
for i in range(t):
	nk = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	n = nk[0]
	k = nk[1]
	a.sort()
	b.sort()
	b.reverse()
	index_a = 0
	index_b = 0
	j = k
	while 0 < j:
		j -= 1
		if a[index_a] < b[index_b]:
			(a[index_a], b[index_b]) = (b[index_a], a[index_b])
			index_b += 1
		index_a += 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	p = sum(x)
	while k:
		l = max(min(x), max(y))
		p = p - min(x) + l
		x.pop(x.index(min(x)))
		y.pop(y.index(max(y)))
		k = k - 1
	print(p)


n = int(input())
for i in range(n):
	(r, k) = map(int, input().split())
	a = [int(aa) for aa in input().split()]
	b = [int(aa) for aa in input().split()]
	a.sort()
	b.sort()
	ans = 0
	for j in range(k):
		ans += max(a[j], b[r - j - 1])
	ans += sum(a[k:])
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	for i in range(k):
		max_b = max(b)
		min_a = min(a)
		if min_a < max_b:
			temp = a[a.index(min_a)]
			a[a.index(min_a)] = b[b.index(max_b)]
			b[b.index(max_b)] = temp
	print(sum(a))


t = int(input())
results = []
for case in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	su = 0
	for i in range(n):
		if k > 0 and b[i] > a[i]:
			su += b[i]
			k -= 1
		else:
			su += a[i]
	results.append(su)
for result in results:
	print(result)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	i = 1
	while k and i <= n:
		if A[i - 1] < B[-i]:
			A[i - 1] = B[-i]
			i += 1
			k -= 1
		else:
			break
	print(sum(A))


t = int(input())
while t:
	(n, k) = map(int, input().rstrip().split())
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	a.sort()
	b.sort()
	ans = 0
	for i in range(n):
		ans += a[i]
	for i in range(k):
		if b[n - (i + 1)] > a[i]:
			ans += b[n - (i + 1)]
			ans -= a[i]
	print(ans)
	t -= 1


T = int(input())
for _ in range(T):
	(N, K) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	k = 1
	res = [sum(a)]
	for _ in range(N):
		if k > K:
			break
		aswap = min(a)
		bswap = max(b)
		a[a.index(aswap)] = bswap
		b[b.index(bswap)] = aswap
		res.append(sum(a))
		k += 1
	print(max(res))


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in range(k):
		temp = max(b)
		a.append(temp)
		b.remove(temp)
		temp2 = min(a)
		a.remove(temp2)
	print(sum(a))


n = int(input())
for j in range(n):
	c = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	for i in range(c[1]):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))


for _ in range(int(input())):
	(n, k) = [int(j) for j in input().split()]
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	a.sort()
	b.sort()
	(p1, p2, count) = (0, n - 1, 0)
	result = 0
	while count < k and p1 < n:
		if a[p1] < b[p2]:
			count += 1
			result += b[p2]
		else:
			result += a[p1]
		p1 += 1
		p2 -= 1
	while p1 < n:
		result += a[p1]
		p1 += 1
	print(result)


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	(i, j) = (0, 0)
	ans = 0
	for _ in range(n):
		if a[i] < b[j] and k > 0:
			ans += b[j]
			j += 1
			k -= 1
		else:
			ans += a[i]
			i += 1
	print(ans)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
while t > 0:
	nk = input()
	nk = nk.split()
	n = int(nk[0])
	k = int(nk[1])
	arrA = input()
	arrA = list(map(int, arrA.split()))
	arrA.sort()
	arrB = input()
	arrB = list(map(int, arrB.split()))
	arrB.sort(reverse=True)
	for i in range(k):
		if arrB[i] > arrA[i]:
			arrA[i] = arrB[i]
	result = 0
	for x in arrA:
		result = result + x
	print(result)
	t = t - 1


def sol():
	T = int(input())
	for _ in range(T):
		(n, k) = map(int, input().split())
		A = list(map(int, input().split()))
		B = list(map(int, input().split()))
		A.sort()
		B.sort(reverse=True)
		(a_idx, b_idx, count) = (0, 0, 0)
		while a_idx < len(A) and b_idx < len(B) and (count < k):
			if A[a_idx] < B[b_idx]:
				A[a_idx] = B[b_idx]
				a_idx += 1
				b_idx += 1
				count += 1
			else:
				break
		print(sum(A))
sol()


n = int(input())
for i in range(n):
	(n, k) = [int(x) for x in input().split()]
	a = [int(y) for y in input().split()]
	b = [int(z) for z in input().split()]
	c = 1
	while c <= k:
		a.sort()
		b.sort()
		b.reverse()
		if a[0] < b[0]:
			q = a[0]
			a[0] = b[0]
			b[0] = q
			c += 1
		else:
			break
	print(sum(a))


def solve():
	input1 = list(map(int, input().split()))
	n = input1[0]
	k = input1[1]
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	sum2 = 0
	kk = 0
	for j in range(0, n):
		if kk < k:
			if b[j] > a[j]:
				sum2 += b[j]
				kk += 1
			else:
				sum2 += a[j]
		else:
			sum2 += a[j]
	print(sum2)
t = int(input())
for tt in range(0, t):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	if k == 0 or max(b) <= min(a):
		print(sum(a))
	else:
		for i in range(k):
			if b[i] > a[i]:
				a[i] = b[i]
		print(sum(a))


t = int(input())
q = 0
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	for m in range(k):
		if a[m] < b[len(b) - 1 - m]:
			a[m] = b[len(b) - 1 - m]
	for w in a:
		q += w
	print(q)
	q = 0


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

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

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	(n, k) = zz()
	lst1 = szzz()
	lst2 = szzz()[::-1]
	s = 0
	for (i, j) in zip(lst1, lst2):
		if k >= 1:
			s += max(i, j)
			k -= 1
			continue
		s += i
	print(s)


def max_swap_sum(a, b, k):
	sorted_a = sorted(a)
	sorted_b = sorted(b)
	if k == 0:
		return sum(sorted_a)
	else:
		i = 0
		while k > 0:
			if sorted_a[i] >= sorted_b[n - 1 - i]:
				break
			sorted_a[i] = sorted_b[n - 1 - i]
			k -= 1
			i += 1
		return sum(sorted_a)
t = int(input())
for t_itr in range(t):
	nk = list(map(int, input().rstrip().split()))
	n = int(nk[0])
	k = int(nk[1])
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	result = max_swap_sum(a, b, k)
	print(result)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	total = sum(a)
	mini = a[0]
	indi = 0
	index = n - 1
	for i in range(min(k, n)):
		if index >= 0 and b[index] > mini:
			total += abs(b[index] - mini)
			indi += 1
			if indi < n:
				mini = a[indi]
			index -= 1
	print(total)


n = int(input())
for _ in range(n):
	(leng, k) = [int(x) for x in input().split()]
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(x) for x in input().split()], reverse=True)
	summator = 0
	i = 0
	while i < k:
		if b[i] > a[i]:
			summator += b[i]
			i += 1
		else:
			break
	print(summator + sum(a[i:]))


for _ in range(int(input())):
	(n, k) = map(int, input().strip().split(' '))
	arr = list(map(int, input().strip().split(' ')))
	brr = list(map(int, input().strip().split(' ')))
	arr.sort()
	brr.sort(reverse=True)
	(i, j) = (0, 0)
	while k > 0 and i < n and (j < n) and (arr[i] < brr[j]):
		arr[i] = brr[j]
		i += 1
		j += 1
		k -= 1
	print(sum(arr))


_ = input
a = lambda : [*map(int, input().split())]
for i in range(int(_())):
	(z, x, y) = [a() for i in ' ' * 3]
	z = z[1]
	y = [i for i in y if i > min(x)]
	if len(y) < 1:
		0
	else:
		for j in ' ' * z:
			x.remove(min(x))
			x += [max(y)]
			y.remove(max(y))
			if len(y) == 0 or max(y) <= min(x):
				break
	print(sum(x))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	f = sum(a)
	for i in range(k):
		if min(a) >= max(b):
			break
		else:
			f -= min(a)
			f += max(b)
			del a[a.index(min(a))]
			del b[b.index(max(b))]
	print(f)


t = int(input())
for T in range(t):
	(n, k) = [int(num) for num in input().split()]
	a = sorted([int(aS) for aS in input().split()], reverse=False)
	b = sorted([int(bS) for bS in input().split()], reverse=True)
	for i in range(k):
		(a[0], b[0]) = (max(b[0], a[0]), min(b[0], a[0]))
		a = sorted(a, reverse=False)
		b = sorted(b, reverse=True)
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort(reverse=True)
	b.sort(reverse=True)
	sumi = 0
	j = 0
	h = 0
	for i in range(n):
		if a[h] > b[j]:
			sumi += a[h]
			h += 1
		elif k == 0:
			sumi += a[h]
			h += 1
		else:
			sumi += b[j]
			k -= 1
			j += 1
	print(sumi)


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split(None, n)[:n]))
	b = list(map(int, input().split(None, n)[:n]))
	a.sort()
	b.sort()
	count = 0
	for y in range(n):
		for z in range(n)[::-1]:
			if a[y] < b[z] and count < k:
				temp = a[y]
				a[y] = b[z]
				b[z] = temp
				count += 1
	sum = 0
	for y in range(n):
		sum += a[y]
	print(sum)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	my_a = sorted(list(map(int, input().split())))
	my_b = sorted(list(map(int, input().split())))
	my_b.reverse()
	for j in range(k):
		if my_a[j] < my_b[j]:
			my_a[j] = my_b[j]
	print(sum(my_a))


from itertools import combinations

def helper(smarter, num):
	ans = 0
	perms = combinations(smarter.keys(), num)
	for perm in perms:
		cur = 1.0
		for p in smarter:
			if p in perm:
				cur *= smarter[p]
			else:
				cur *= 1 - smarter[p]
		ans += cur
	return ans

def solve():
	(n, k) = map(int, input().split())
	a = map(int, input().split())
	b = map(int, input().split())
	a = sorted(a)
	b = sorted(b)
	i = 0
	j = len(b) - 1
	while k > 0 and i < len(a) and (j >= 0) and (a[i] < b[j]):
		(a[i], b[j]) = (b[j], a[i])
		i += 1
		j -= 1
		k -= 1
	print(sum(a))

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


import sys
input = sys.stdin.buffer.readline

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			temp = a[i]
			a[i] = b[i]
			b[i] = temp
		else:
			break
	return sum(a)
t = int(input())
while t:
	t -= 1
	print(main())


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	a = a + b[:k]
	a.sort()
	print(sum(a[k:]))


n = int(input())
for i in range(n):
	rep = list(map(int, input().split()))
	index = rep[0]
	rep = rep[1]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	u = -1
	while rep > 0:
		for k in range(index):
			if a[k] < b[u]:
				a[k] = b[u]
				u = u - 1
				break
		rep = rep - 1
	print(sum(a))


t = int(input())
for dud in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
		else:
			break
	total = 0
	for i in a:
		total += i
	print(total)


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


test = int(input())
li3 = []
for i in range(test):
	(n, k) = map(int, input().split())
	li1 = list(map(int, input().split()))
	li2 = list(map(int, input().split()))
	lis1 = sorted(li1)
	lis2 = sorted(li2, reverse=True)
	for j in range(k):
		if lis1[j] < lis2[j]:
			lis1[j] = lis2[j]
	li3.append(sum(lis1))
for i in li3:
	print(i)


for lo in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	i = 0
	j = 0
	s = 0
	while i < n and j < k:
		if a[i] < b[i]:
			s += b[i]
		else:
			break
		i += 1
		j += 1
	for l in range(i, n):
		s += a[l]
	print(s)


from bisect import insort
for _ in range(int(input())):
	(n, k) = tuple(map(int, input().split()))
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	res = sum(a)
	i = 0
	while i < k and i < n:
		min_a = a[0]
		max_b = b[-1]
		if min_a > max_b:
			break
		res += max_b - min_a
		del a[0]
		del b[-1]
		insort(a, max_b)
		insort(b, min_a)
		i += 1
	print(res)


def merge_sort_asc(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		left = arr[:mid]
		right = arr[mid:]
		left = merge_sort_asc(left)
		right = merge_sort_asc(right)
		arr = []
		while len(left) > 0 and len(right) > 0:
			if left[0] < right[0]:
				arr.append(left[0])
				left.pop(0)
			else:
				arr.append(right[0])
				right.pop(0)
		for i in left:
			arr.append(i)
		for i in right:
			arr.append(i)
	return arr

def merge_sort_dsc(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		left = arr[:mid]
		right = arr[mid:]
		left = merge_sort_dsc(left)
		right = merge_sort_dsc(right)
		arr = []
		while len(left) > 0 and len(right) > 0:
			if left[0] > right[0]:
				arr.append(left[0])
				left.pop(0)
			else:
				arr.append(right[0])
				right.pop(0)
		for i in left:
			arr.append(i)
		for i in right:
			arr.append(i)
	return arr
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = merge_sort_asc(a)
	b = merge_sort_dsc(b)
	for i in range(k):
		small = a[i]
		big = b[i]
		if small < big:
			a[i] = big
			b[i] = small
	j = 0
	for i in range(n):
		j = j + a[i]
	print(j)


num = int(input())
while num > 0:
	num = num - 1
	(n, k) = input().split()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(int(k)):
		a1 = min(a)
		b1 = max(b)
		if b1 >= a1:
			a.remove(a1)
			a.append(b1)
			b.append(a1)
			b.remove(b1)
	print(sum(a))


for _ in range(int(input().strip())):
	(n, k) = list(map(int, input().strip().split(' ')))
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	a.sort()
	b.sort(reverse=True)
	l = sum(a)
	ans = [l]
	while k > 0:
		sa = sum(a[0:k])
		sb = sum(b[0:k])
		if sb > sa:
			ans.append(l + sb - sa)
		else:
			ans.append(l)
		k -= 1
	print(max(ans))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ad = 0
	take = 0
	for j in range(k):
		c = max(b)
		d = min(a)
		if c > d:
			ad += c
			b.remove(c)
			a.remove(d)
	print(sum(a) + ad)


t = int(input())
for q in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	(n, k) = (L[0], L[1])
	ch = input()
	a = [int(i) for i in ch.split()]
	ch = input()
	b = [int(i) for i in ch.split()]
	a.sort()
	b.sort(reverse=True)
	s = 0
	for i in range(k):
		s += max(b[i], a[i])
	for i in range(k, n):
		s += a[i]
	print(s)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	a.sort()
	su = sum(a)
	b.sort(reverse=True)
	for i in range(n):
		if a[i] >= b[i]:
			break
		else:
			if k == 0:
				break
			a[i] = b[i]
			k -= 1
			if sum(a) > su:
				su = sum(a)
			elif sum(a) <= su:
				break
	print(su)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	f = []
	s = []
	a = input().split()
	for j in a:
		f.append(int(j))
	b = input().split()
	for j in b:
		s.append(int(j))
	if min(f) >= max(s):
		print(sum(f))
	elif k == 0:
		print(sum(f))
	else:
		for j in range(k):
			t1 = min(f)
			t2 = max(s)
			if t1 > t2:
				break
			else:
				f.remove(t1)
				f.append(t2)
				s.remove(t2)
				s.append(t1)
		print(sum(f))


r = int(input())
for _ in range(r):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(k):
		a_ind = a.index(min(a))
		b_ind = b.index(max(b))
		if a[a_ind] < b[b_ind]:
			a[a_ind] = b[b_ind]
		del b[b.index(max(b))]
		if len(b) == 0:
			break
	print(sum(a))


t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l2.sort()
	l1.sort()
	sum = 0
	idx2 = n - 1
	idx1 = 0
	while m > 0 and idx1 < n and (idx2 < n):
		if l1[idx1] == l2[idx2]:
			sum += l1[idx1]
			idx1 += 1
		elif l1[idx1] > l2[idx2]:
			sum += l1[idx1]
			idx1 += 1
		elif l1[idx1] < l2[idx2]:
			m -= 1
			sum += l2[idx2]
			idx2 -= 1
			idx1 += 1
	for i in range(idx1, n):
		sum += l1[i]
	print(sum)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	sum_a = 0
	sum_b = 0
	for i in range(k):
		if a[i] < b[-(i + 1)]:
			sum_a += a[i]
			sum_b += b[-(i + 1)]
		else:
			break
	print(sum(a) + sum_b - sum_a)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	alist = list(map(int, input().split()))
	blist = list(map(int, input().split()))
	alist = sorted(alist)
	blist = sorted(blist, reverse=True)
	tot = sum(alist[k:])
	for i in range(k):
		if alist[i] < blist[i]:
			tot += blist[i]
		else:
			tot += alist[i]
	print(tot)


test_cases = int(input())
for z in range(test_cases):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	ans = 0
	for i in a:
		ans += i
	print(ans)


t = int(input())
for i in range(t):
	(l, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort()
	b.reverse()
	s = sum(a[k:])
	for i in range(k):
		s += max(a[i], b[i])
	print(s)


from sys import stdin
t = int(stdin.readline().strip())
while t != 0:
	t -= 1
	(n, k) = list(map(int, stdin.readline().strip().split()))
	a = list(map(int, stdin.readline().strip().split()))
	b = list(map(int, stdin.readline().strip().split()))
	a = sorted(a)
	b = sorted(b, reverse=True)
	i = 0
	j = 0
	swaps = 0
	while i < n and j < n and (swaps < k):
		if a[i] < b[j]:
			(a[i], b[j]) = (b[j], a[i])
			swaps += 1
			i += 1
			j += 1
		else:
			break
	print(sum(a))


T = int(input())
for t in range(T):
	(N, K) = [int(_) for _ in input().split()]
	A = [int(_) for _ in input().split()]
	B = [int(_) for _ in input().split()]
	A = sorted(A)
	B = sorted(B, reverse=True)
	i = 0
	s = sum(A)
	while i < K and A[i] < B[i]:
		s += B[i] - A[i]
		i += 1
	print(s)


for ad in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort()
	b.reverse()
	a.sort()
	for i in range(k):
		if b[i] > a[i]:
			a[i] = b[i]
		else:
			break
	print(sum(a))


testcase = int(input())
for t in range(1, testcase + 1):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b = sorted(b, reverse=True)
	(swaps, i) = (0, 0)
	while i < n and swaps < k:
		if a[i] <= b[i]:
			a[i] = b[i]
			swaps += 1
		i += 1
	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()))
	for i in range(m):
		x = max(b)
		y = min(a)
		if x > y:
			a.remove(y)
			b.remove(x)
			a.append(x)
	print(sum(a))


n = int(input())
for i in range(n):
	(p, q) = map(int, input().split())
	lis1 = list(map(int, input().split()))
	lis2 = list(map(int, input().split()))
	lis1.sort()
	lis2 = sorted(lis2, reverse=True)
	s = 0
	if p > q:
		s = sum(lis1[q:])
		for j in range(q):
			s += max(lis1[j], lis2[j])
		print(s)
	else:
		for j in range(p):
			s += max(lis1[j], lis2[j])
		print(s)


def single_integer():
	return int(input())

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

def string():
	return input()

def multi_string():
	return input().split()
t = single_integer()
for i in range(t):
	(n, k) = multi_integer()
	a = list(multi_integer())
	a.sort()
	b = list(multi_integer())
	b.sort(reverse=True)
	j = 0
	while j < k:
		if b[j] <= a[j]:
			break
		else:
			(a[j], b[j]) = (b[j], a[j])
			j += 1
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	res = 0
	for i in range(n):
		if A[-1] >= B[-1] or k == 0:
			res += A.pop()
		else:
			res += B.pop()
			k -= 1
	print(res)


def logic():
	return 0
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr1 = sorted(list(map(int, input().split())))
	arr2 = sorted(list(map(int, input().split())), reverse=True)
	for a in range(k):
		if arr1[a] < arr2[0]:
			temp = arr1[a]
			arr1[a] = arr2[0]
			arr2[0] = temp
			arr2 = sorted(arr2, reverse=True)
		else:
			break
	print(sum(arr1))


for _ in range(int(input())):
	(_, k) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()))
	s = sum(a)
	for i in range(k):
		if b[-1] > a[i]:
			s += b.pop() - a[i]
	print(s)


t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a = sorted(a)
	b = sorted(b)[::-1]
	ia = 0
	ib = 0
	while ia < n and ib < n and (b[ib] > a[ia]) and (k > 0):
		a[ia] = b[ib]
		ia += 1
		ib += 1
		k -= 1
	print(sum(a))


t = int(input())
for i in range(t):
	(n, k) = tuple(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	l = 0
	while min(a) < max(b) and l < k:
		(aind, bind) = (a.index(min(a)), b.index(max(b)))
		(a[aind], b[bind]) = (b[bind], a[aind])
		l += 1
	print(sum(a))


t = int(input())
for _ in range(t):
	a = list()
	b = list()
	c = list()
	(n, k) = [int(x) for x in input().split()]
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	a.sort()
	b.sort()
	for x in range(k):
		c.append(a[x])
		c.append(b[n - 1 - x])
	c.sort()
	a = a[k:]
	for x in range(k):
		a.append(c[len(c) - 1 - x])
	print(sum(a))


rw = int(input())
for ewqr in range(rw):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	b.reverse()
	s = sum(a)
	i = 0
	while i < k and b[i] > a[i]:
		s += b[i] - a[i]
		i += 1
	print(s)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import time, random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	rr = []
	for ti in range(t):
		(n, k) = LI()
		a = sorted(LI())
		b = sorted(LI(), reverse=True)
		for i in range(k):
			if a[i] >= b[i]:
				break
			a[i] = b[i]
		rr.append(sum(a))
	return JA(rr, '\n')
print(main())


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	while k > 0:
		if min(a) < max(b):
			(a[a.index(min(a))], b[b.index(max(b))]) = (b[b.index(max(b))], a[a.index(min(a))])
		k -= 1
	print(sum(a))


for _ in range(int(input())):
	r = [int(i) for i in input().split()]
	(n, k) = (r[0], r[1])
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	a.sort()
	b.sort(reverse=True)
	step = 0
	swap = 0
	for i in range(len(b)):
		if b[i] > a[step] and swap < k:
			a[step] = b[i]
			step += 1
			swap += 1
	print(sum(a))


c = int(input())
for x in range(c):
	i = 0
	(_, k) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr1.sort()
	arr2 = list(map(int, input().split()))
	arr2.sort(reverse=True)
	while i < k:
		if arr1[i] < arr2[i]:
			arr1[i] = arr2[i]
		i += 1
	print(sum(arr1))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	j = 0
	summ = 0
	for l in range(n):
		summ += a[l]
	counter = 0
	while counter < k and j != n:
		if a[j] < b[n - j - 1]:
			summ += b[n - j - 1] - a[j]
			counter += 1
			j += 1
		else:
			break
	print(summ)


from typing import List

def _sum_abs_difference(a):
	return sum((abs(a[i + 1] - a[i]) for i in range(len(a) - 1)))

def problem_a():
	t = int(input())
	for test_case in range(1, t + 1):
		(n, m) = map(int, input().split())
		if n == 1:
			print(0)
		elif n == 2:
			print(m)
		else:
			print(2 * m)
		continue

def max_swap(a: List, b: List, k: int):
	n = len(a)
	for attempt in range(k):
		min_a = min(a)
		i = a.index(min_a)
		max_b = max(b)
		if min_a >= max_b:
			break
		j = b.index(max_b)
		tmp = a[i]
		a[i] = b[j]
		b[j] = tmp
	return sum(a)

def problem_b():
	t = int(input())
	for test_case in range(1, t + 1):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		print(max_swap(a, b, k))
problem_b()


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		a.sort()
		b.sort()
		b = b[::-1]
		su = 0
		j = 0
		l = 0
		for i in a:
			if k <= 0:
				break
			if i < b[j]:
				su += b[j]
				j += 1
				k -= 1
			else:
				su += i
			l += 1
		print(su + sum(a[l:]))
	return
main()


t = int(input())
answer = []
for _ in range(t):
	(n, k) = map(int, input().split())
	array_a = list(map(int, input().split()))[:n]
	array_b = list(map(int, input().split()))[:n]
	array_a.sort()
	array_b.sort()
	array_b.reverse()
	b_len = len(array_b) - 1
	i = 0
	for j in range(0, k):
		if array_a[i] < array_b[j]:
			array_a[i] = array_b[j]
		i += 1
	summ_array = answer.append(sum(array_a))
for i in answer:
	print(i)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	min_a = min(a)
	max_b = max(b)
	res = sum(a)
	for i in range(k):
		a.sort()
		b.sort()
		min_a = min(a)
		max_b = max(b)
		if min_a < max_b:
			tem = a[a.index(min_a)]
			a[a.index(min_a)] = b[b.index(max_b)]
			b[b.index(max_b)] = tem
			tem_res = sum(a)
			if tem_res > res:
				res = tem_res
	print(res)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	for _ in range(k):
		a.sort()
		if a[0] < b[0]:
			a[0] = b[0]
			b.pop(0)
	print(sum(a))


import math
import os
import random
import re
import sys

def algo(n, k, a, b):
	if k == 0:
		return sum(a)
	a = sorted(a)
	(a1, a2) = (a[:k], a[k:])
	bb = sorted(b)[-k:]
	cc = sorted(a1 + bb)[-k:]
	return sum(cc) + sum(a2)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(algo(n, k, a, b))


t = int(input())
for T in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort(reverse=True)
	ind = 0
	while k > 0 and ind < n:
		if a[ind] < b[ind]:
			k -= 1
			(a[ind], b[ind]) = (b[ind], a[ind])
		ind += 1
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a.sort()
	b = [int(x) for x in input().split()]
	b.sort(reverse=True)
	i = 0
	j = 0
	tt = 0
	while tt < k and i < n and (j < n):
		if a[i] < b[j]:
			a[i] = b[j]
			i += 1
			j += 1
			tt += 1
		else:
			break
	print(sum(a))


import sys

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

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

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())
t = fi()
while t > 0:
	t -= 1
	(n, m) = mi()
	a = li()
	b = li()
	a.sort()
	b.sort(reverse=True)
	c = []
	for i in range(n):
		c.append(b[i] - a[i])
	c.sort(reverse=True)
	s = 0
	for i in range(m):
		if c[i] < 0:
			break
		s += c[i]
	print(sum(a) + s)


def max_subary(a, b, moves):
	a.sort()
	b.sort()
	a_index = 0
	b_index = len(a) - 1
	while moves and a_index < len(a) and (b_index >= 0):
		if a[a_index] < b[b_index]:
			(a[a_index], b[b_index]) = (b[b_index], a[a_index])
			moves -= 1
		a_index += 1
		b_index -= 1
	return sum(a)
no = int(input())
for i in range(0, no):
	(array_length, total_moves) = [int(i) for i in input().split(' ')]
	a = [int(a) for a in input().split(' ')]
	b = [int(b) for b in input().split(' ')]
	print(max_subary(a, b, total_moves))


def solve():
	(m, n) = input().split()
	m = int(m)
	n = int(n)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while n > 0:
		if min(a) < max(b):
			minpos = a.index(min(a))
			maxpos = b.index(max(b))
			(a[minpos], b[maxpos]) = (b[maxpos], a[minpos])
		n -= 1
	return sum(a)
T = int(input())
for t in range(T):
	print(solve())


test = int(input())
for _ in range(test):
	(n, k) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	lst1.sort()
	lst2.sort(reverse=True)
	s = 0
	q = 0
	count = 0
	for i in range(n):
		if count == k:
			break
		for j in range(q, n):
			if lst2[j] > lst1[i]:
				lst1[i] = lst2[j]
				count += 1
				q = j + 1
				break
	print(sum(lst1))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l = sorted(l)
	l1 = sorted(l1)
	for i in range(len(l)):
		if l[i] < l1[-1] and k != 0:
			(l[i], l1[-1]) = (l1[-1], l[i])
			l1.pop()
			k -= 1
		else:
			break
	print(sum(l))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	b.reverse()
	i = 0
	for j in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
		i += 1
	print(sum(a))


for case in range(int(input())):
	ans = 0
	(n, k) = [int(a) for a in input().split()]
	a = sorted([int(a) for a in input().split()])
	b = sorted([int(a) for a in input().split()], reverse=True)
	for i in range(k):
		if a[i] <= b[i]:
			ans += b[i]
		else:
			ans += a[i]
	ans += sum(a[k:])
	print(ans)


t = int(input())
for t in range(0, t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in range(0, k):
		x = min(a)
		y = max(b)
		x_index = a.index(x)
		y_index = b.index(y)
		if y > x:
			a[x_index] = y
			b[y_index] = x
	x = sum(a)
	print(x)


from sys import stdin
input = stdin.readline
for Ti in range(int(input().strip())):
	(n, k) = [int(x) for x in input().strip().split()]
	a = [int(x) for x in input().strip().split()]
	b = [int(x) for x in input().strip().split()]
	a.sort(reverse=False)
	b.sort(reverse=True)
	i = 0
	sa = sum(a)
	while i < k:
		if a[i] >= b[i]:
			break
		sa += b[i] - a[i]
		i += 1
	print(sa)


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for tt in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
	print(sum(a))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	count = 0
	for i in range(k):
		if a[i] < b[i]:
			count += 1
		else:
			break
	sunn = sum(b[:count]) + sum(a[count:])
	print(sunn)


t = int(input())
for i in range(t):
	nk = list(map(int, input().split()))
	n = nk[0]
	k = nk[1]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while k != 0:
		elem1 = max(b)
		elem2 = min(a)
		if elem1 > elem2:
			(b[b.index(elem1)], a[a.index(elem2)]) = (a[a.index(elem2)], b[b.index(elem1)])
		else:
			break
		k -= 1
	sumi = 0
	for i in range(len(a)):
		sumi += a[i]
	print(sumi)


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	l = input().split()
	a = [int(i) for i in l]
	l = input().split()
	b = [int(i) for i in l]
	lfi = []
	for i in a:
		lfi.append((i, 0))
	for i in b:
		lfi.append((i, 1))
	lfi.sort()
	lfi.reverse()
	sumi = 0
	numofel = 0
	while numofel < n:
		if lfi[0][1] == 1:
			if k > 0:
				sumi += lfi[0][0]
				k -= 1
				numofel += 1
				lfi.pop(0)
			else:
				lfi.pop(0)
		else:
			sumi += lfi[0][0]
			lfi.pop(0)
			numofel += 1
	print(sumi)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	for i in range(k):
		if min(a) < max(b):
			a1 = a.index(min(a))
			b1 = b.index(max(b))
			(a[a1], b[b1]) = (b[b1], a[a1])
	c = sum(a)
	print(c)


t = input()
t = int(t)
while t > 0:
	t -= 1
	nk = input()
	(n, k) = nk.split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:n]
	a.sort()
	b.sort(reverse=True)
	for i in range(n):
		if k == 0:
			break
		if a[i] < b[i]:
			a[i] = b[i]
			k -= 1
		else:
			break
	print(str(sum(a)))


import math
t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	arr.sort()
	brr.sort(reverse=True)
	i = 0
	cc = 0
	while i < len(arr) and cc < k:
		if arr[i] < brr[i]:
			arr[i] = brr[i]
			i += 1
			cc += 1
		else:
			break
	print(sum(arr))


t = int(input())
for case in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	total = sum(a)
	a = sorted(a)
	b.sort(reverse=True)
	c = 0
	for i in range(n):
		if a[i] < b[i]:
			(a[i], b[i]) = (b[i], a[i])
			c += 1
			if c == k:
				break
	total2 = sum(a)
	if k == 0:
		print(total)
	elif total < total2:
		print(total2)
	else:
		print(total)


from sys import stdin, stdout
import math

def main():
	t = int(stdin.readline())
	for _ in range(t):
		(n, k) = map(int, stdin.readline().split())
		a = [int(k) for k in input().split()]
		b = [int(k) for k in input().split()]
		a.sort()
		b.sort(reverse=True)
		sm = 0
		for i in range(n):
			if b[i] > a[i] and k > 0:
				sm += b[i]
				k -= 1
			else:
				sm += a[i]
		print(sm)
main()


def solve():
	(a, b) = list(map(int, input().split()))
	arr = sorted(list(map(int, input().split())))
	brr = sorted(list(map(int, input().split())), reverse=True)
	for i in range(b):
		if arr[i] < brr[i]:
			temp = arr[i]
			arr[i] = brr[i]
			brr[i] = temp
	print(sum(arr))
for i in range(int(input())):
	solve()


t = int(input())
while t > 0:
	(n, k) = list(map(int, input().split()))
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())), reverse=True)
	i = 0
	while i < k:
		if b[i] > a[i]:
			temp = a[i]
			a[i] = b[i]
			b[i] = temp
		else:
			break
		i = i + 1
	print(sum(a))
	t = t - 1


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
import math
import time

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

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

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, val, ans):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		v = val ** 5 - mid ** 5
		print(v)
		if v == ans:
			print('HOHOHOH')
			return mid
		elif v < ans:
			return binary(mid + 1, r, val, ans)
		else:
			return binary(l, mid - 1, val, ans)

def check(n):
	v = 1
	while n != 0:
		if n % 10 == 0 or n % 10 == 1:
			n = n // 10
		else:
			v = 0
			break
	return v

def stairs(n, m, val, c, l):
	if val > n:
		return 100000
	elif val == n:
		if l[val] != -1:
			return l[val]
		elif c % m == 0:
			l[val] = c
			return l[val]
		else:
			l[val] = 100000
			return l[val]
	else:
		l[val] = min(stairs(n, m, val + 1, c + 1, l), stairs(n, m, val + 2, c + 1, l))
		return l[val]

def fact(n):
	if n == 0 or n == 1:
		return 1
	else:
		return n * fact(n - 1)

def some(n):
	s = 0
	while n != 0:
		s += fact(n % 10)
		n //= 10
	return s

def bin(l, r, val, ll):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if ll[mid] == val:
			return mid
		elif ll[mid] > val:
			return bin(l, mid - 1, val, ll)
		else:
			return bin(mid + 1, r, val, ll)

def fn(n):
	c = -1
	for i in range(2, int(sqrt(n)) + 1):
		if n % 2 == 0:
			c = i
			break
	if c == -1:
		c = n
	return c
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort(reverse=True)
	j = 0
	while k != 0:
		if a[j] < b[j]:
			temp = b[j]
			b[j] = a[j]
			a[j] = temp
		else:
			break
		k -= 1
		j += 1
	print(sum(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	s = [sum(a)]
	b = sorted(list(map(int, input().split())))
	for i in range(k):
		a.pop(0)
		a.append(b[-1])
		b.pop()
		s.append(sum(a))
	print(max(s))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	first_array = list(map(int, input().split()))
	second_array = list(map(int, input().split()))
	first_array.sort()
	second_array.sort(reverse=True)
	for i in range(k):
		if first_array[i] < second_array[i]:
			first_array[i] = second_array[i]
	print(sum(first_array))


t = int(input())
for i in range(t):
	(n, k) = (int(x) for x in input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	curr_a = sum(a)
	a.sort()
	b.sort()
	improvement = 0
	for j in range(k):
		if a[j] < b[-(j + 1)]:
			improvement += b[-(j + 1)] - a[j]
		else:
			break
	print(curr_a + improvement)


from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
for __ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	y = n - 1
	for i in range(k):
		if a[i] < b[y]:
			a[i] = b[y]
			y -= 1
		else:
			break
	print(sum(a))


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	a.sort()
	b.sort()
	i = j = n - 1
	sum1 = 0
	while i >= 0 and j >= 0 and (n > 0):
		if k > 0 and b[j] > a[i]:
			sum1 += b[j]
			j -= 1
			k -= 1
		else:
			sum1 += a[i]
			i -= 1
		n -= 1
	print(sum1)
	t -= 1


t = int(input())
for _ in range(t):
	s = input()
	n = int(s.split(' ')[0])
	k = int(s.split(' ')[1])
	a_str = input()
	b_str = input()
	a = [int(x) for x in a_str.split(' ')]
	b = [int(x) for x in b_str.split(' ')]
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] > b[i]:
			break
		else:
			a[i] = b[i]
	print(sum(a))


import math

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

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

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

def si():
	return input()

def pYes():
	print('YES')

def pNo():
	print('NO')

def plist(l):
	print(''.join(l))
t = int(input())
for i in range(t):
	(n, k) = ri()
	a = li()
	b = li()
	a.sort()
	b.sort(reverse=True)
	for i in range(k):
		if a[i] < b[i]:
			a[i] = b[i]
		else:
			break
	print(sum(a))