#include using namespace std; int main(){ int n,h,m,t; cin >> n >> h >> m >> t; m += (n-1) * t; while(m >= 60){ h++; m -= 60; } cout << h << endl << m << endl; return 0; }