using namespace std; #include #include #include #include #include #include #include typedef long long ll; ll INF = LLONG_MAX; int main() { ll N, H, M, T; cin >> N >> H >> M >> T; ll x = H * 60 + M + (N - 1) * T; x %= 24 * 60; cout << x / 60 << endl; cout << x % 60 << endl; }