#include #include #include #include #include //--------------------------- using namespace std; //--------------------------- #define REP(i,n) for(int i = 0; i < (n); i++) #define P(x) cout << (x) << "\n" //--------------------------- int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); int n,h,m,t;cin >> n >> h >> m >> t; int H = 0,M = 0; H = (h + ((n - 1) * t + m) / 60) % 24; M = ((n - 1) * t + m) % 60; P(H);P(M); return 0; }