import qualified Data.Text as T import qualified Data.Text.IO as TI import Control.Applicative hiding (empty) import Control.Arrow import Data.Monoid import Data.Foldable readLines = sequence.flip replicate TI.getLine readInt::String->Int readInt=read parse (x:y:[]) = let len=length y time=readInt x num=12*time `div` 1000 miss=if num < len then len-num else 0 num_=if num < len then num else len in (num_,miss) main = do m <- readInt<$>getLine list <-fmap (fmap (T.unpack).T.split(==' '))<$>readLines m let (good,miss) =(getSum***getSum) $ foldMap (Sum***Sum) $fmap parse list putStrLn$show good++" "++show miss