#include main(){ int N,H,M,T; scanf("%d%d%d%d",&N,&H,&M,&T); int time = T*(N-1) % 1440; int m = (M+time) % 60; time /= 60; if(M > m)time++; int h = (H+time) % 24; printf("%d\n%d\n",h,m); }