import Control.Monad

main :: IO ()
main = do
  wl <- replicateM 10 readLn
  kl <- replicateM 10 readLn
  putStrLn $ solve wl kl

solve :: [Int] -> [Int] -> String
solve l1 l2 = (show $ top3 l1) ++ " " ++ (show $ top3 l2)
  where
    top3 :: [Int] -> Int
    top3 = sum . take 3 . sort
      where
        sort :: [Int] -> [Int]
        sort [] = []
        sort (x:xs) = (sort [i | i <- xs, i >= x] ++ [x]) ++ (sort [j | j <- xs, j < x])