#include #include #include using namespace std; int main() { int n, h, m, t; cin >> n >> h >> m >> t; int a = (((60 * h) + m + (n - 1)*t) / 60) % 24; int b = ((60 * h) + m + (n - 1)*t) % 60; cout << a << endl<