import Control.Monad
import Data.Maybe
import Control.Applicative

totalDist :: [Int] -> Maybe (Int, Int)
totalDist [] = Nothing
totalDist [_] = Nothing
totalDist [_, _] = Nothing
totalDist (i:d1:d2:_) = Just (i, d1 + d2)

findMax :: [(Int, Int)] -> (Int, Int) -> (Int, Int)
findMax [] a = a
findMax (x:xs) a =
  if snd x > snd a
    then findMax xs x
    else findMax xs a


solver :: [[Int]] -> (Int, Int)
solver [] = (-1, -1)
solver xs =
  let ys = mapMaybe totalDist xs -- ys :: [(Int, Int)]
  in
      findMax ys (0, 0)

main :: IO()
main = do
  n <- (read :: String -> Int) <$> getLine
  unless (n == 0) $ do
     line <- map (map (read :: String -> Int) . words) <$> replicateM n getLine
     let m = solver line
     putStrLn $ show (fst m) ++ " " ++ show (snd m)
     main