#include <iostream>
using namespace std;
int main(){
int h1, m1, h2, m2;
while(cin>>h1>>m1>>h2>>m2){
int sum;
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;
}
}