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