sleep_count, alarm_hour, alarm_minutes, alarm_cycle = map(int, input().split()) convert_alarm_minutes = alarm_hour * 60 + alarm_minutes if sleep_count > 1: for i in range(1, sleep_count): convert_alarm_minutes += alarm_cycle if convert_alarm_minutes > 3600: convert_alarm_minutes -= 3600 wakeup_hour, wakeup_minutes = divmod(convert_alarm_minutes, 60) print(wakeup_hour) print(wakeup_minutes)