n, h, m, L = map(int, input().split()) dh, m = divmod(m + L * (n - 1), 60) h += dh print(h) print(m)