a,b,c,d=map(int,input().split())
if d>=b:
    f=d-b
    e=c-a
elif d<b:
    f=d+60-b
    e=c-1-a
print(e,f)
/**************************************************************
	Problem: 1462
	User: admin
	Language: Python
	Result: Accepted
	Time:199 ms
	Memory:34480 kb
****************************************************************/