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