#include <iostream>
using namespace std;
int main()
{
int h1,h2,m1,m2,th,tm;
while(cin>>h1>>m1){
cin>>h2>>m2;
if(h1>h2)
th=24-h1+h2;
else if(h1<h2)
th=h2-h1;
else{
if(m1>m2)
th=24-h1+h2;
else
th =0;
}
if (m1>m2){
th--;
tm=m2-m1+60;
}else
tm=m2-m1;
cout<<th<<" "<<tm<<endl;
}
return 0;
}