#include #include #include using namespace std; int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); int N, H, M, T; cin >> N >> H >> M >> T; int duration = (T * (N-1)) % 1440; int cur = 60 * H + M; int next = (cur + duration) % 1440; int next_h = next / 60; int next_m = next % 60; cout << next_h << endl; cout << next_m << endl; return 0; }