#include //cin, cout #include //vector #include //sort,min,max,count #include //string,getline, to_string #include //abs(int) #include //swap, pair #include //deque #include //INT_MAX #include //bitset using namespace std; int main() { int N, H, M, T; cin >> N >> H >> M >> T; int temp = T * (N - 1) + M; int h = (H + (temp / 60)) % 24; int m = temp % 60; cout << h << endl; cout << m << endl; return 0; }