integer::N,H,M,T,time read *, N,H,M,T time = MOD((H*60+M)+T*(N-1),1440) print '(i0)', time/60, MOD(time,60) end program