#include int main(void){ int N,H,M,T,LastH,LastM; scanf("%d",&N); scanf("%d",&H); scanf("%d",&M); scanf("%d",&T); LastH=(H+(N-1)*T/60)%24; LastM=(M+T*(N-1))%60; printf("%d\n",LastH); printf("%d\n",LastM); return 0; }