#include #include #include using namespace std; int main() { int n, h, m, t; cin >> n >> h >> m >> t; t = t * (n - 1); h = (h + t / 60) % 24; m = (m + t % 60) % 60; cout << h << endl; cout << m << endl; return 0; }