module Main where

import           Debug.Trace
import qualified Data.Vector.Unboxed           as VU
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char


getVUIntFromInputLineAtBSC8 :: IO (VU.Vector Int)
getVUIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
getListIntFromInputLineAtBSC8 =
    unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
main :: IO ()
main = do
    [aX, aY, aA, aB, aC] <- getListIntFromInputLineAtBSC8
    aP                   <- getVUIntFromInputLineAtBSC8
    aQ                   <- getVUIntFromInputLineAtBSC8
    aR                   <- getVUIntFromInputLineAtBSC8

    let vP = VU.snoc (VU.fromList (sortConved (VU.toList aP) aX)) 0
    let vQ = VU.snoc (VU.fromList (sortConved (VU.toList aQ) aY)) 0
    let vR = VU.snoc (VU.fromList (sortConved (VU.toList aR) (aX + aY))) 0
    putStrLn $ show (sumApple vP vQ vR aX aY 0)


sortConved :: [Int] -> Int -> [Int]
sortConved _        0 = []
sortConved []       _ = []
sortConved (x : []) 1 = [x]
sortConved (x : xs) c = if lgteq == (c - 1)
    then (sortConved gteq lgteq)  ++ [x]
    else if lgteq >= c
        then (sortConved gteq c)
        else (sortConved gteq lgteq) ++ [x] ++ (sortConved lt (c - 1 - lgteq))
  where
    gteq  = filter (\y -> y >= x) xs
    lt    = filter (\y -> y < x) xs
    lgteq = length gteq




sumApple
    :: VU.Vector Int
    -> VU.Vector Int
    -> VU.Vector Int
    -> Int
    -> Int
    -> Int
    -> Int
sumApple reds greens nils tX tY tZ
    | (tX + tY) == tZ = 0
    | otherwise = if (maxNum == red) && (tX > 0)
        then red + (sumApple (VU.tail reds) greens nils (tX - 1) tY tZ)
        else if ((max green nil) == green) && (tY > 0)
            then green + (sumApple reds (VU.tail greens) nils tX (tY - 1) tZ)
            else nil + (sumApple reds greens (VU.tail nils) tX tY (tZ + 1))

  where
    red    = VU.head reds
    green  = VU.head greens
    nil    = VU.head nils
    maxNum = max red (max green nil)
