import Control.Monad (replicateM)
import Data.List (sortBy)

main = do
    nums <- replicateM 20 readLn :: IO [Int]
    let ws = take 10 nums
    let ks = drop 10 nums
    putStrLn $ unwords $ map show [point ws, point ks]
    where
    point xs = sum $ take 3 $ sortBy (flip compare) xs