#include int main(void) { // your code goes here int n, h, m, t; int wh, wm; scanf("%d %d %d %d", &n,&h,&m,&t); wh=h+(m+(n-1)*t)/60; wm=(m+(n-1)*t)%60; printf("%d\n",wh); printf("%d\n",wm); return 0; }