Thanks to computer technology the functionality of phone systems has been greatly enhanced in the last ten years. We have automated menus, sophisticated answering machines, conference call capabilities, group addressing and so on. A common feature of a company's phone system is the ability to set call forwarding. For example, if Bob at the Nobody's Home Company (NHC) goes on vacation, he sets things up so that all calls coming to him are forwarded to his associate Jane. This problem addresses how phone systems might keep track of call forwarding.
The phones at the NHC all have four digit extensions. Employees can set call forwarding by entering the appropriate information through their telephone interface. If an employee is going to be away they enter the following information: their extension, the time they are leaving, how long they will be away, and the extension that their calls should be forwarded to, with the following constraints:
All extensions consist of four digits.
The extensions 0000 and 9999 are reserved for special use and will not be entered as information by an employee.
Times are recorded in increments of 1 hour and are based on a clock that begins at 0000 at midnight every New Year's Eve. Therefore, when describing the time they are leaving, employees always use an integer between 0000 and 8784 (which is 366*24). The call forwarding system is completely reset at the beginning of the year.
A call forward set to start at time X for a duration of Y will be in effect from time X to time X+Y inclusive.
Users are ``good" about the requests they enter. They follow the format rules. They do not enter a request such that the duration of the request would go past the end of the year. They do not enter two requests for their extension that overlap in time. Even though the users enter correct, clear, non-overlapping information from their own point of view, a degenerate situation can still occur in a call forwarding system, if requests have been made in such a way as to forward a call back to the original target of the call. For example if Bob forwards his calls to Sue, and Sue forwards her calls to Joe, and Joe forwards his calls to Bob then when somebody calls any of these three people their calls would be forwarded forever. To prevent this situation the call forwarding system uses the ``dead end" number 9999. Any calls made to an extension involved in such a degenerate situation will be forwarded to the special 9999 extension.