#include using namespace std; using ll = long long; using PII = std::pair; using PLL = std::pair; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) int main() { #ifdef DEBUG cout << "DEBUG MODE" << endl; ifstream in("input.txt"); //for debug cin.rdbuf(in.rdbuf()); //for debug #endif int n, h, m, t; cin >> n >> h >> m >> t; t *= (n - 1); t %= 24 * 60; h += t / 60; m += t % 60; h += m / 60; m %= 60; h %= 24; cout << h << endl; cout << m << endl; // for (auto z : rmq) // cout << z << " "; // cout << endl; return 0; }