$/=' ' n,h,m,t=$<.map &:to_i p (h+(m+=n*t-t)/60)%24,m%60