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