#include using namespace std; struct Time { int hour, min; Time (int h, int m) : hour(h), min(m) { hour += (min / 60); min %= 60; hour %= 24; } void add_time (int h = 0, int m = 0) { hour += h; min += m; hour += (min / 60); min %= 60; hour %= 24; } }; int main() { int n, h, m, k; cin >> n >> h >> m >> k; Time t(h, m); t.add_time(0, (n - 1) * k); cout << t.hour << '\n'; cout << t.min << '\n'; return 0; }