#include #include typedef unsigned long long ul; typedef signed long long ll; int main(void) { std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); ll n, h, m, t; std::cin >> n >> h >> m >> t; m += t * (n-1); h += m / 60; h %= 24; m %= 60; std::cout << h << std::endl << m << std::endl; return 0; }