#include #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using pii = pair; int main() { int n, h, m, t; cin >> n >> h >> m >> t; int nh = (h + t * (n - 1) / 60) % 24; int nm = (m + t * (n - 1)) % 60; cout << nh << endl; cout << nm << endl; return 0; }