{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE BangPatterns #-} import Control.Applicative import Control.Monad import Control.Arrow import Data.List import Data.Maybe import Data.Char import Text.Printf readInt = ( readLn :: IO Int ) readInts = map ( read :: String -> Int ) . words <$> getLine which a b f = if f then a else b mp [ a, b ] = ( a, b ) main = do [ n, h, m, t ] <- readInts let mins = h * 60 + m + ( n - 1 ) * t print $ mins `div` 60 `mod` 24 print $ mins `mod` 60