import Control.Applicative
import Control.Monad

qsort :: [Int] -> [Int]
qsort [] = []
qsort (p:xs) = qsort gteq ++ [p] ++ qsort lt
  where gteq = [x | x <- xs, x >= p]
        lt   = [x | x <- xs, x < p ]

solver :: [Int] -> [Int] -> String
solver [] _ = []
solver _ [] = []
solver ws ks =
  let sortedws = qsort ws
      sortedks = qsort ks
      scoreW = sum $ take 3 sortedws
      scoreK = sum $ take 3 sortedks
  in
      show scoreW ++ " " ++ show scoreK


main :: IO()
main = do
  contents <- map (read :: String -> Int) <$> replicateM 20 getLine
  let (w,k) = splitAt 10 contents
  putStrLn $ solver w k