#include using namespace std; int main() { unsigned int n, h, m, t, work; scanf("%d %d %d %d", &n, &h, &m, &t); work = t * (n - 1); cout << (h + work / 60) % 24 + (m + work > 60 ? 1 : 0) << endl; cout << (m + work) % 60 << endl; return 0; }