#include #include #include #include #include #include #include #include #include #include #include #include #define INF 10000000 #define PI 3.14159265358979323846 using namespace std; typedef long long ll; typedef pair p; typedef queue qi; typedef queue< pair > qp; typedef vector vi; typedef vector vii; typedef vector< pair > vp; int dx[4] = { 0, 1, 0, -1 }; int dy[4] = { 1, 0, -1, 0 }; int main(){ ios::sync_with_stdio(false); int n,h,m,t; cin >> n >> h >> m >> t; int num = 1, ansh = h, ansm = m; while(num < n){ ansm += t; num++; while(ansm >= 60){ ansh++; if(ansh == 24) ansh = 0; ansm -= 60; } } cout << ansh << endl << ansm << endl; return 0; }