EPS/2024/02/05-02-24/b.py

19 lines
370 B
Python

import bisect
def main():
n_tests = int(input())
for _ in range(n_tests):
n, m = [int(i) for i in input().split()]
ai = [int(i) for i in input().split()]
bj = [int(i) for i in input().split()]
ai.sort()
for i in range(m):
tmp = ai.pop(0)
bisect.insort(ai, bj[i])
print(sum(ai))
main()