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