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