# your code goes here
H, M = map(int, input().split())
if 0 <= H <= 23 and 0 <= M <= 59:
    if M < 45:
        N_M = abs(M - 45)
        if H == 0:
            print(23, 60 - N_M)
        else:
            print(H - 1, 60 - N_M)
    else:
        print("H, M")