#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
int s1,f1;
if(d>b){
f1=d-b;
s1=c-a;
cout<<s1<<" "<<f1<<endl;
return 0;
}else if(d<b){
d+=60;
c-=1;
f1=d-b;
s1=c-a;
cout<<s1<<" "<<f1<<endl;
return 0;
}else{
f1=d-b;
cout<<f1<<endl;
return 0;
}
return 0;
}