#include using namespace std; typedef long long ll; // Welcome to my source code! int main() { ll n, h, m, t; cin >> n >> h >> m >> t; m += (n - 1) * t; h += m / 60; m %= 60; h %= 24; cout << h << '\n' << m << endl; }