#include<bits/stdc++.h>
using namespace std;


int main(){
    int hik_min, hik_sec, magn_min, magn_sec;
    cin>>hik_min>>hik_sec>>magn_min>>magn_sec;
    hik_sec += 60*hik_min;
    magn_sec += 60*magn_min;

    if(magn_sec < hik_sec){
        cout<<-1<<'\n';
        return 0;
    } 
    if(magn_sec == hik_sec){
        hik_sec--;
    }
    cout<<hik_sec/60<<" "<<hik_sec%60<<endl;
}