import Data.List main = putStrLn . unwords . map show . foldl f [0,0] . map words . drop 1 . lines =<< getContents where f [a,b] [t,s] = [a+ad,b+bd] where ad = min (length s) ((read t)*3`div`250) bd = length s - ad