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