N, H, M, T = map(int, input().split()) sleep_minutes = T*N fab = M + sleep_minutes q, mod = divmod(fab, 60) print(H + q) print(mod)