#include using namespace std; #define REP(i,N) for(i=0;i P; typedef struct{ int first; int second; int third; }T; //昇順 bool comp_Se(T& l, T& r){ return l.second < r.second; } int main(void){ int N,H,M,T; int d=1440; int h=24; int m=60; cin >> N >> H >> M >> T; T=(((N-1)%d)*T)%d; M=(M+T%m); H=(H+T/m+M/m)%h; M%=m; cout << H << endl << M << endl; return 0; }