#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 = (h + mm / 60) % 24; cout << h << endl << m << endl; return 0; }