{-# LANGUAGE StrictData #-}

import Data.List

main = interact $  (++"\n") . show . solve . map (map read . words) . lines

solve :: [[Int]] -> Int
solve ([[x, y, a, b, c], red, green, coll]) =
  sum $ best (x + y) $ (best x red) ++ (best y green) ++ coll
    where
      best n = take n . sortBy (flip compare) 