#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i) #define all(a) (a).begin(), (a).end() int main() { cin.tie(nullptr); ll N, H, M, T; cin >> N >> H >> M >> T; M += T * (N - 1); H += M / 60; M %= 60; H %= 24; cout << H << ' ' << M << '\n'; }