#include int main(void) { int N,H,M,T; scanf("%d%d%d%d",&N,&H,&M,&T); int n,h,m,t; h=H; m=M+(T*(N-1)); if(m<60){ printf("%d\n",h); printf("%d\n",m); }else if(m>=60) printf("%d\n",h+1); printf("%d\n",m-60); return 0; }