package main import . "fmt" func main() { var n,h,m,t int Scan(&n,&h,&m,&t) x:=h*60+m+n*t-t Println((x/60)%24) Println(x%60) }