#include using namespace std; int main(){ string s; long long n; int h, m, t; cin >> n >> h >> m >> t; if (60-m > t*(n-1) ){ cout << h << endl; cout << m+t*(n-1) << endl; }else{ cout << (h+ (m+t*(n-1))/60 ) % 24 << endl; cout << m+t*(n-1) %60 << endl; } }