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