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")
