CodeEff/ECCO huggingface dataset:
# Original solution
import heapq

xi = 0
yi = 0
zi = 0
def next(i):
    global xi, yi, zi, p, q, r
    if i == 0:
        xi += 1
        return heapq.nlargest(xi, p)[-1]
    elif i == 1:
        yi += 1
        return heapq.nlargest(yi, q)[-1]
    else:
        zi += 1
        return heapq.nlargest(zi, r)[-1]

x, y, a, b, c = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

ns = [next(0), next(1), next(2)]

val = 0

while x + y - xi - yi - zi + 3 > 0:
    if ns[0] >= ns[1] and ns[0] >= ns[2]:
        val += ns[0]
        if len(p) > 0 and x - xi > 0:
            ns[0] = next(0)
        else:
            xi += 1
            ns[0] = 0
    elif ns[0] <= ns[1] and ns[1] >= ns[2]:
        val += ns[1]
        if len(q) > 0 and y - yi > 0:
            ns[1] = next(1)
        else:
            yi += 1
            ns[1] = 0
    else:
        val += ns[2]
        if len(r) > 0:
            ns[2] = next(2)
        else:
            ns[2] = 0
print(val)


# Optimized solution
import heapq

x, y, a, b, c = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p2 = heapq.nlargest(x, p)
q2 = heapq.nlargest(y, q)
r2 = heapq.nlargest(x+y, r)
p2.append(0)
q2.append(0)
r2.append(0)

pi = 0
qi = 0
ri = 0

val = 0

for _ in range(x+y):
    if p2[pi] >= q2[qi] and p2[pi] >= r2[ri]:
        val += p2[pi]
        pi += 1
    elif p2[pi] <= q2[qi] and q2[qi] >= r2[ri]:
        val += q2[qi]
        qi += 1
    else:
        val += r2[ri]
        ri += 1

print(val)
# Original solution
from bisect import bisect_left, insort_left
from collections import deque
import sys
def main():
	readlines = sys.stdin.readline
	x,y,a,b,c = list(map(int,input().split()))

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

	p.sort()
	q.sort()
	r.sort(reverse=True)

	p = p[a-x:]
	q = q[b-y:]
	ans = sum(p) + sum(q)
	p_count = 0
	q_count = 0

	for i in range(c):
		if p[p_count] < r[i] and q[q_count] < r[i]:
			if p[p_count] < q[q_count]:
				ans -= p[p_count]
				ans += r[i]
				insort_left(p,r[i])
				p_count += 1
			else:
				ans -= q[q_count]
				ans += r[i]
				insort_left(q,r[i])
				q_count += 1
		elif p[p_count] < r[i]:
			ans -= p[p_count]
			ans += r[i]
			insort_left(p,r[i])
			p_count += 1
		elif q[q_count] < r[i]:
			ans -= q[q_count]
			ans += r[i]
			insort_left(q,r[i])
			q_count += 1
		else:
			break

	print(ans)
if __name__ == '__main__':
	main()

# Optimized solution
x,y,a,b,c = list(map(int,input().split()))

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

p.sort()
q.sort()
r.sort(reverse=True)

p = p[a-x:]
q = q[b-y:]

p.extend(q)
p.sort()

ans = sum(p)
count = 0
for i in range(c):
	if p[i] < r[i]:
		ans += r[i] - p[i]
	else:
		break
print(ans)
# Original solution
import sys
input=sys.stdin.readline
x,y,a,b,c=list(map(int,input().split()))

a_list=list(map(int,input().split()))
a_list=sorted(a_list)
b_list=list(map(int,input().split()))
b_list=sorted(b_list)
a_list=a_list[-x:]
b_list=b_list[-y:]
c_list=list(map(int,input().split()))
for i in range(c):
    c_list[i]=-c_list[i]
import heapq
heapq.heapify(a_list)
heapq.heapify(b_list)
heapq.heapify(c_list)

flag=True
while flag and c_list:
    x=heapq.heappop(c_list)
    x=x*(-1)
    #ｃ_listの中でのもっとも大きい値
    min_a=heapq.heappop(a_list)
    min_b=heapq.heappop(b_list)
    if min(min_a,min_b)>=x:
        flag=False
        heapq.heappush(a_list,min_a)
        heapq.heappush(b_list,min_b)
    else:
        if min_a>=min_b:
            heapq.heappush(a_list,min_a)
            heapq.heappush(b_list,x)
            
        elif min_a<min_b:
            heapq.heappush(b_list,min_b)
            heapq.heappush(a_list,x)

sum_a=sum(list(a_list))
sum_b=sum(list(b_list))

print((sum_a+sum_b))
            

    


# Optimized solution
x,y,a,b,c=list(map(int,input().split()))

a_list=list(map(int,input().split()))
a_list=sorted(a_list)
b_list=list(map(int,input().split()))
b_list=sorted(b_list)
a_list=a_list[-x:]
b_list=b_list[-y:]
c_list=list(map(int,input().split()))
for i in range(c):
    c_list[i]=-c_list[i]
import heapq
heapq.heapify(a_list)
heapq.heapify(b_list)
heapq.heapify(c_list)

flag=True
while flag and c_list:
    x=heapq.heappop(c_list)
    x=x*(-1)
    #ｃ_listの中でのもっとも大きい値
    min_a=heapq.heappop(a_list)
    min_b=heapq.heappop(b_list)
    if min(min_a,min_b)>=x:
        flag=False
        heapq.heappush(a_list,min_a)
        heapq.heappush(b_list,min_b)
    else:
        if min_a>=min_b:
            heapq.heappush(a_list,min_a)
            heapq.heappush(b_list,x)
         
        elif min_a<min_b:
            heapq.heappush(b_list,min_b)
            heapq.heappush(a_list,x)

sum_a=sum(list(a_list))
sum_b=sum(list(b_list))

print((sum_a+sum_b))
# Original solution
x, y, a, b, c = list(map(int, input().split()))
Lista = sorted(list(map(int, input().split())), reverse = True)
Listb = sorted(list(map(int, input().split())), reverse = True)
Listc = sorted(list(map(int, input().split())), reverse = True)
if x < a:
    del Lista[x:a]
if y < b:
    del Listb[y:b]
List = sorted(Lista + Listb, reverse = True)
while len(Listc) > 0:
    if List[-1] < Listc[0]:
        List[-1] = Listc[0]
        List = sorted(List, reverse = True)
        del Listc[0]
    else:
        break
print((sum(List)))

# Optimized solution
x, y, a, b, c = list(map(int, input().split()))
Lista = sorted(list(map(int, input().split())), reverse = True)
Listb = sorted(list(map(int, input().split())), reverse = True)
Listc = sorted(list(map(int, input().split())), reverse = True)
if x < a:
    del Lista[x : a]
if y < b:
    del Listb[y : b]
List = sorted(Lista + Listb, reverse = True)
i = -1
for n in range(min(x + y, c)):
    if List[-n-1] < Listc[n]:
        i = n
    else:
        break
del List[x + y - i -1 : x + y]
del Listc[i + 1 : c]
print((sum(List) + sum(Listc)))
# Original solution
from collections import deque
x,y,a,b,c = list(map(int,input().split()))

p = deque(sorted(list(map(int,input().split()))))
q = deque(sorted(list(map(int,input().split()))))
r = deque(sorted(list(map(int,input().split()))))

ans = deque(maxlen=(x+y))

def insertion(z):
	global x,y
	if z == p:
		x -= 1
	else:
		y -= 1
	return ans.append(z.pop())

while x > 0 or y > 0:
	if x and y:
		if p[-1] > q[-1] :
			insertion(p)
		else:
			insertion(q)
	elif not x:
		insertion(q)
	else:
		insertion(p)

while r:
	if ans[-1] < r[-1]:
		ans.appendleft(r.pop())
	else:
		break

print((sum(ans)))



# Optimized solution
x,y,a,b,c = list(map(int,input().split()))
p = sorted(map(int,input().split()), reverse = True)
q = sorted(map(int,input().split()), reverse = True)
r = sorted(map(int,input().split()), reverse = True)
ans = sorted(p[:x]+q[:y]+r,reverse = True)
print((sum(ans[:x+y])))
# Original solution
import heapq
import sys
X, Y, A, B, C = list(map(int, input().split()))
Av = list(map(int, input().split()))
Bv = list(map(int, input().split()))
Cv = list(map(int, input().split()))
heapq.heapify(Av)
heapq.heapify(Bv)
heapq.heapify(Cv)
for i in range(A-X):
    heapq.heappop(Av)
for i in range(B-Y):
    heapq.heappop(Bv)
if C > X+Y:
    for i in range(C-(X+Y)):
        heapq.heappop(Cv)
    NotTake = X+Y
else:
    NotTake = C
total = X+Y
C = NotTake
for _ in range(NotTake):
    Amin = heapq.heappop(Av)
    Bmin = heapq.heappop(Bv)
    Cmin = heapq.heappop(Cv)
    if X > 0 and Amin == min(Amin, Bmin, Cmin):
        heapq.heappush(Bv, Bmin)
        heapq.heappush(Cv, Cmin)
        X -= 1
    elif Y > 0 and Bmin == min(Bmin, Cmin):
        heapq.heappush(Av, Amin)
        heapq.heappush(Cv, Cmin)
        Y -= 1
    elif C > 0:
        heapq.heappush(Av, Amin)
        heapq.heappush(Bv, Bmin)
        C -= 1
    if X == 0 or Y == 0 or C == 0:
        break
NotTake = X+Y+C-total
if X == 0:
    Iv = Bv
    Jv = Cv
    I = Y
    J = C
elif Y == 0:
    Iv = Av
    Jv = Cv
    I = X
    J = C
else:
    print((sum(Av)+sum(Bv)+sum(Cv)))
    sys.exit()

for _ in range(NotTake):
    Imin = heapq.heappop(Iv)
    Jmin = heapq.heappop(Jv)
    if I > 0 and Imin == min(Imin, Jmin):
        heapq.heappush(Jv, Jmin)
        I -= 1
    elif J > 0:
        heapq.heappush(Iv, Imin)
        J -= 1
    if J == 0 or I == 0:
        break

print((sum(Av)+sum(Bv)+sum(Cv)))


# Optimized solution
def LI():
    return list(map(int, input().split()))


X, Y, A, B, C = LI()
red = LI()
green = LI()
mu = LI()
red.sort(reverse=True)
green.sort(reverse=True)
ans = red[:X]+green[:Y]+mu
ans.sort(reverse=True)
total = 0
for i in range(X+Y):
    total += ans[i]
print(total)
# Original solution
x,y,a,b,c=list(map(int,input().split())) #x,yだけ見る。
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
s=sorted(p+q+r, reverse=True)
cntr,cntg,ans=0,0,0
for i in range(a+b+c):
    if cntr<x and (s[i] in set(p) or s[i] in set(r)):
        ans+=s[i]
        cntr+=1
    elif cntg<y and (s[i] in set(q) or s[i] in set(r)):
        ans+=s[i]
        cntg+=1
print(ans)

# Optimized solution
x,y,a,b,c=list(map(int,input().split())) #x,yだけ見る。
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=sorted(p,reverse=True)[:x]
q=sorted(q,reverse=True)[:y]
print((sum(sorted(p+q+r, reverse=True)[:x+y])))
# Original solution
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

p = deque(p)
q = deque(q)
r = deque(r)

ans = 0
MIN = -1
N = X + Y
for _ in range(N):
    tmp_p, tmp_q, tmp_r = MIN, MIN, MIN
    if len(p) > 0 and X > 0:
        tmp_p = p.popleft()
    if len(q) > 0 and Y > 0:
        tmp_q = q.popleft()
    if len(r) > 0:
        tmp_r = r.popleft()
    
    if tmp_p >= tmp_q and tmp_p >= tmp_r:
        ans += tmp_p
        X -= 1
        if tmp_q != -1:
            q.appendleft(tmp_q)
        if tmp_r != -1:
            r.appendleft(tmp_r)

    elif tmp_q >= tmp_p and tmp_q >= tmp_r:
        ans += tmp_q
        Y -= 1
        if tmp_p != -1:
            p.appendleft(tmp_p)
        if tmp_r != -1:
            r.appendleft(tmp_r)

    else:
        ans += tmp_r
        if tmp_q != -1:
            q.appendleft(tmp_q)
        if tmp_p != -1:
            p.appendleft(tmp_p)

print(ans)


# Optimized solution
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

cand = sorted(p[:X] + q[:Y] + r, reverse=True)
print((sum(cand[:X+Y])))
# Original solution
x,y,a,b,c = list(map(int,input().split()))
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)
result = sum(p[0:x]) + sum(q[0:y])
red = x-1
green = y-1
colorless = 0
#print(p,q,r)
while colorless < c:
	#print(red,green,colorless)
	if red >= 0 and green >= 0:
		if p[red] < q[green]:
			if r[colorless] > p[red]:
				result -= p[red]
				result += r[colorless]
				colorless += 1
				red -= 1
			else:
				break
		else:
			if r[colorless] > q[green]:
				result -= q[green]
				result += r[colorless]
				colorless += 1
				green -= 1
			else:
				break
	elif red >= 0:
		if r[colorless] > p[red]:
			result -= p[red]
			result += r[colorless]
			colorless += 1
			red -= 1
		else:
			break
	elif green >= 0:
		if r[colorless] > q[green]:
			result -= q[green]
			result += r[colorless]
			colorless += 1
			green -= 1
		else:
			break
print(result)

# Optimized solution
x,y,a,b,c = list(map(int,input().split()))
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)
apples = p[0:x]+q[0:y]+r
print((sum(sorted(apples,reverse=True)[0:x+y])))
# Original solution
x,y,a,b,c = list(map(int,input().split()))
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)
ans = 0
for i in range(x,max(-1,x-c-1),-1):
  z = c-(x-i)
  for j in range(y,max(-1,y-1-z),-1):
    ans = max(ans,sum(p[:i])+sum(q[:j])+sum(r[:(x+y-i-j)]))
print(ans)

# Optimized solution
x,y,a,b,c = list(map(int,input().split()))
p = sorted(list(map(int,input().split())),reverse=True)[:x]
q = sorted(list(map(int,input().split())),reverse=True)[:y]
r = list(map(int,input().split()))
print((sum(sorted(p+q+r,reverse=True)[:(x+y)])))
# Original solution
x,y,A,B,C=list(map(int,input().split()))
R=list(map(int,input().split()))
G=list(map(int,input().split()))
N=list(map(int,input().split()))
arr=[]
for i in range(A):
    arr.append([R[i],-1])
for i in range(B):
    arr.append([G[i],-2]) 
for i in range(C):
    arr.append([N[i],-3])    
arr.sort(reverse=True)
ans=0
adv=0
for i in range(len(arr)):
    if x+y==adv:
        break
    if arr[i][1]==-1:
        if x>0:
            ans+=arr[i][0]
            x-=1 
    elif arr[i][1]==-2:
        if y>0:    
            ans+=arr[i][0]
            y-=1
    else:
        ans+=arr[i][0]
        adv+=1 
        
print(ans)        

# Optimized solution
import sys 
x,y,A,B,C=list(map(int,sys.stdin.readline().split()))
R=list(map(int,sys.stdin.readline().split()))
G=list(map(int,sys.stdin.readline().split()))
N=list(map(int,sys.stdin.readline().split()))
arr=[]
for i in range(A):
    arr.append([R[i],-1])
for i in range(B):
    arr.append([G[i],-2]) 
for i in range(C):
    arr.append([N[i],-3])    
arr.sort(reverse=True)
ans=0
adv=0
for i in range(len(arr)):
    if x+y==adv:
        break
    if arr[i][1]==-1:
        if x>0:
            ans+=arr[i][0]
            x-=1 
    elif arr[i][1]==-2:
        if y>0:    
            ans+=arr[i][0]
            y-=1
    else:
        ans+=arr[i][0]
        adv+=1 
        
print(ans)
# Original solution
from heapq import heapify, heappop, heappush

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

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
r = [-x for x in r]

p.sort()
q.sort()
r.sort()

p = p[-x:]
q = q[-y:]

heapify(p)
heapify(q)
heapify(r)

is_p = True
is_q = True

while is_p and is_q and r:
    pp = heappop(p)
    qq = heappop(q)
    rr = heappop(r)

    if pp <= qq:
        heappush(q, qq)
        if pp < -rr:
            heappush(p, -rr)
        else:
            is_p = False
            heappush(p, pp)
            heappush(r, rr)
    else:
        heappush(p, pp)
        if qq < -rr:
            heappush(q, -rr)
        else:
            is_q = False
            heappush(q, qq)
            heappush(r, rr)

print((sum(p) + sum(q)))

# Optimized solution
from heapq import heapify, heappop, heappush

x, y, a, b, c = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

r = [-x for x in r]

p.sort()
q.sort()
r.sort()

p = p[-x:]
q = q[-y:]

heapify(p)
heapify(q)
heapify(r)

while r:
    pp = heappop(p)
    qq = heappop(q)
    rr = heappop(r)
    rr *= -1

    if pp >= rr and qq >= rr:
        heappush(p, pp)
        heappush(q, qq)
        break

    elif pp <= qq:
        heappush(q, qq)
        if pp < rr:
            heappush(p, rr)
    else:
        heappush(p, pp)
        if qq < rr:
            heappush(q, rr)

print((sum(p) + sum(q)))
# Original solution
X,Y,A,B,C = list(map(int, input().split()))
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
newp = p[:X]
newq = q[:Y]
lis = newp + newq
lis.sort(reverse = True)
s = sum(lis)
for i in range(len(r)):
    if lis[-i-1] < r[i]:
        s = s - lis[-i-1] + r[i]
    else:
        break
print(s)


# Optimized solution
#X,Y,A,B,C = map(int, input().split())
#p = [int(x) for x in input().split()]
#q = [int(x) for x in input().split()]
#r = [int(x) for x in input().split()]
#p.sort(reverse = True)
#q.sort(reverse = True)
#r.sort(reverse = True)
#newp = p[:X]
#newq = q[:Y]
#lis = newp + newq
#lis.sort(reverse = True)
#s = sum(lis)
#for i in range(len(r)):
#    if lis[-i-1] < r[i]:
#        s = s - lis[-i-1] + r[i]
#    else:
#        break
#print(s)

X,Y,A,B,C = list(map(int, input().split()))
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]
p.sort(reverse = True)
q.sort(reverse = True)
p = p[:X]
q = q[:Y]
ans = p+q+r
ans.sort(reverse = True)
print((sum(ans[:X+Y])))
# Original solution
X,Y,A,B,C=list(map(int,input().split()))
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=sorted(list(map(int,input().split())),reverse=True)

i=X-1
j=Y-1
k=0

ans=sum(p[:X])+sum(q[:Y])

while k<len(r):
    if i>-1 and j>-1:
        if p[i]<q[j]:
            cmin=p[i]
            i-=1
        else:
            cmin=q[j]
            j-=1
        
        if r[k]<=cmin:
            break
        ans+=r[k]-cmin
        k+=1
    elif i>-1:
        cmin=p[i]
        i-=1

        if r[k]<=cmin:
            break

        ans+=r[k]-cmin
        k+=1
    elif j>-1:
        cmin=q[j]
        j-=1

        if r[k]<=cmin:
            break

        ans+=r[k]-cmin
        k+=1
    else:
        break

print(ans)


# Optimized solution
X,Y,A,B,C=list(map(int,input().split()))
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=sorted(list(map(int,input().split())),reverse=True)

pqr=sorted(p[:X]+q[:Y]+r,reverse=True)

print((sum(pqr[:(X+Y)])))
# Original solution
X, Y, A, B, C = list(map(int, input().split()))
P = [int(a) for a in input().split()]
Q = [int(a) for a in input().split()]
R = [int(a) for a in input().split()]
S = sorted([p * 4 for p in P] + [q * 4 + 1 for q in Q] + [r * 4 + 2 for r in R])[::-1]

Z = X + Y
ans = 0
for s in S:
    a, t = s>>2, s & 3
    if t == 0:
        if X:
            ans += a
            X -= 1
            Z -= 1
    elif t == 1:
        if Y:
            ans += a
            Y -= 1
            Z -= 1
    else:
        ans += a
        Z -= 1
    if not Z: break
print(ans)

# Optimized solution
I = lambda: sorted([int(a) for a in input().split()])[::-1]
X, Y, *_ = list(map(int, input().split()))
print((sum(sorted(I()[:X] + I()[:Y] + I())[::-1][:X+Y])))
# Original solution
X, Y, A, B, C = list(map(int, input().split()))
 
p = sorted(list(map(int,input().split())), reverse=True)[:X]
q = sorted(list(map(int,input().split())), reverse=True)[:Y]
r = sorted(list(map(int,input().split())), reverse=True)
 
for i in r:
    p_min = p[X - 1]
    q_min = q[Y - 1]
 
    if p_min > i and q_min > i:
        break
 
    p_min_diff = i - p_min
    q_min_diff = i - q_min
 
    if p_min_diff >= q_min_diff and p_min_diff > 0:
        p.pop()
        p.insert(0, i)
    elif q_min_diff >= p_min_diff and q_min_diff > 0:
        q.pop()
        q.insert(0, i)
 
print((sum(p) + sum(q)))

# Optimized solution
X, Y, A, B, C = list(map(int, input().split()))
 
p = sorted(list(map(int,input().split())), reverse=True)[:X]
q = sorted(list(map(int,input().split())), reverse=True)[:Y]
r = sorted(list(map(int,input().split())), reverse=True)
 
colored_p = []
colored_q = []
 
for i in r:
    p_min = p[len(p) - 1] if len(p) > 0 else colored_p[len(colored_p) - 1]
    q_min = q[len(q) - 1] if len(q) > 0 else colored_q[len(colored_q) - 1]
 
    if p_min > i and q_min > i:
        break
 
    p_min_diff = i - p_min
    q_min_diff = i - q_min
 
    if p_min_diff >= q_min_diff and p_min_diff > 0:
        if len(p) > 0:
            p.pop()
        colored_p.append(i)
    elif q_min_diff >= p_min_diff and q_min_diff > 0:
        if len(q) > 0:
            q.pop()
        colored_q.append(i)
 
print((sum(p) + sum(q) + sum(colored_p) + sum(colored_q)))
# Original solution
X, Y, A, B, C = list(map(int, input().split()))
p = sorted(list(map(int, input().split())), reverse = True)
q = sorted(list(map(int, input().split())), reverse = True)
r = sorted(list(map(int, input().split())), reverse = True)
S = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)
i = 0
ans = 0
a = 0
b = 0
c = 0
while i < (X + Y):
  if S[0] == r[0]:
    c += 1
    r.remove(r[0])
    ans += S[0]
    i += 1
  elif S[0] == p[0] and a < X:
    a += 1
    p.remove(p[0])
    ans += S[0]
    i += 1
  elif S[0] == q[0] and b < Y:
    b += 1
    q.remove(q[0])
    ans += S[0]
    i += 1
  S.remove(S[0])
print(ans)

# Optimized solution
X, Y, A, B, C = list(map(int, input().split()))
p = sorted(list(map(int, input().split())), reverse = True)
q = sorted(list(map(int, input().split())), reverse = True)
r = sorted(list(map(int, input().split())), reverse = True)
S = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)
print((sum(S[:X+Y])))
# Original solution
import collections
x,y,aa,bb,cc = list(map(int,input().split(' ')))

aas = list(map(int, input().split(' ')))
bbs = list(map(int, input().split(' ')))
ccs = list(map(int, input().split(' ')))

aas.sort(key = lambda x:-x)
bbs.sort(key = lambda x:-x)
ccs.sort(key = lambda x:-x)
aas = aas[:x]
bbs = bbs[:y]

r = (aas + bbs)
r.sort()

i = 0
j = 0
while(j < len(ccs) and i < len(r)):
	if ccs[j] > r[i]:
		r[i] = ccs[j]
		i+=1
	j+=1

print(sum(r))

# Optimized solution
x,y,_,_,_ = list(map(int,input().split(' ')))

a,b,c = list(map(int, input().split(' '))),list(map(int, input().split(' '))),list(map(int, input().split(' ')))
a.sort(key = lambda x:-x)
b.sort(key = lambda x:-x)
c.sort(key = lambda x:-x)
r = a[:x] + b[:y]
r.sort()

i,j = 0,0
while(j < len(c) and i < len(r)):
	if c[j] > r[i]:
		r[i] = c[j]
		i +=1
	else:
		break
	j +=1

print(sum(r))
# Original solution
X, Y, A, B, C = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

temp = P[:X] + Q[:Y]

temp.sort()
ans = sum(temp)
for ri in R:
    if temp[0] < ri:
        ans += ri - temp[0]
        temp.pop(0)
    else:
        break

print(ans)

# Optimized solution
X, Y, A, B, C = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)

temp = P[:X] + Q[:Y] + R

temp.sort(reverse=True)
ans = sum(temp[:X+Y])

print(ans)
# Original solution
import heapq
x, y, a, b, c = list(map(int, input().split()))
ps = sorted(list(map(int, input().split())), reverse=True)[:x]
qs = sorted(list(map(int, input().split())), reverse=True)[:y]
rs = sorted(list(map(int, input().split())))
apples = ps + qs
heapq.heapify(apples)
m = heapq.heappop(apples)
M = rs.pop()
while 1:
    if m < M:
        heapq.heappush(apples, M)
        if rs: 
            m = heapq.heappop(apples)
            M = rs.pop()
        else:
            break
    else:
        heapq.heappush(apples, m)
        break 
print((sum(apples)))


# Optimized solution
x, y, a, b, c = list(map(int, input().split()))
ps = sorted(list(map(int, input().split())), reverse=True)[:x]
qs = sorted(list(map(int, input().split())), reverse=True)[:y]
rs = list(map(int, input().split()))
apples = sorted(ps + qs + rs, reverse=True)
print((sum(apples[:x+y])))