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

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

d=sorted(c)

ans=0

for i in range(0,b):

 ans+=d[i]

print(ans)
a,b=list(map(int,input().split()))

c=[]

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

d=list(c)

d2=sorted(d)

ans=0

for i in range(b):

  ans+=d2[i]

print(ans)
a, b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = sorted(c)
ans = 0
for i in range(0, b):
    ans += d[i]
print(ans)

a, b = list(map(int, input().split()))
c = []
c = list(map(int, input().split()))
d = list(c)
d2 = sorted(d)
ans = 0
for i in range(b):
    ans += d2[i]
print(ans)

+c = [] -d = sorted(c) +d = list(c) +d2 = sorted(d) -for i in range(0, b): -    ans += d[i] +for i in range(b): +    ans += d2[i]