-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU main = do nhmt <- getLine putStrLn $ solve nhmt solve nhmt = let (n:h:m:t:_) = map read $ words nhmt tm = t * (n - 1) + m mm = tm `rem` 60 hh = (h + (tm `div` 60)) `rem` 24 in unlines $ map show [hh, mm]