#include int main() { int n, h, m, t; scanf("%d%d%d%d", &n, &h, &m, &t); n += -1; int times = h * 60 + m; for (int i = 0; i < n; i++) { times += t; } h = ((times - times % 60) / 60) % 24; m = times % 60; printf("%d\n%d", h, m); return 0; }