#include int main() { int n, h, m, t; scanf("%d %d %d %d", &n, &h, &m, &t); m += (n - 1) * t; h += m / 60; printf("%d\n%d\n", h % 24, m % 60); return 0; }