#include #define REP(i,n) for(int i=0;i( \ ( std::ostringstream() << std::dec << x ) ).str() #define ALL(s) (s).begin(), (s).end() using namespace std; typedef long long unsigned int llu; typedef long long ll; int main (){ int N,H,M,T; while (cin >> N >> H >> M >> T){ M += T * (N - 1); H += M/60; M %= 60; H %= 24; cout << H << endl << M << endl; } return 0; }