https://www.acmicpc.net/problem/2884
A, B = map(int, input().split()) B -= 45 if B < 0 : A -= 1 B = 60 + B if A < 0 : A = 24 + A print(A, B)