def min2clock(t): m = t % 60 t /= 60 h = t % 60 return h, m def clock2min(h, m): return h*60 + m N, H, M, T = map(int, raw_input().split()) t = clock2min(H, M) for i in xrange(N-1): t = (t + T) % (24 * 60) for x in min2clock(t): print x