($N,$H,$M,$T)=glob<>;print+(($M+=$T*~-$N)/60+$H)%24,$/,$M%60