a=int(input()) b=int(input()) c=int(input()) d=int(input()) a=a60 c=c60 e=a+b f=c+d e=e-f f=e%60 e=e/60 print(e) print(f)