#include //#include //#include //#include #include //#include using namespace std; int main() { long long N, H, M, T; cin >> N >> H >> M >> T; M += T * (N - 1); H += M / 60; M %= 60; H %= 24; cout << H << endl; cout << M << endl; return 0; }