N, K = list(map(int,input().split()))

p = list(map(int,input().split()))



list.sort(p)

total = 0

for i in range(K):

	total += p[i]

print(total)
N,K = list(map(int,input().split()))

list = list(map(int,input().split()))



list.sort()



total=0

for i in range(K):

	total+=list[i]

print(total)
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
list.sort(p)
total = 0
for i in range(K):
    total += p[i]
print(total)

N, K = list(map(int, input().split()))
list = list(map(int, input().split()))
list.sort()
total = 0
for i in range(K):
    total += list[i]
print(total)

-p = list(map(int, input().split())) -list.sort(p) +list = list(map(int, input().split())) +list.sort() -    total += p[i] +    total += list[i]