A = list(map(int,input().split())) h = A(1) m = A(2) n = A(0) L = A(3) L = L*(n-1) m = m + L while m > 60 : m -= 60 h += 1 print(h) print(m)