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