#include using namespace std; int main(){ int N, H, M, T; cin >> N >> H >> M >> T; cout << (H * 60 + M + T * (N - 1)) / 60 << (H * 60 + M + T * (N - 1)) % 60 << endl; }