Calculating Flight Duration

Time Limit: 1 Second    Memory Limit: 32768 KB

Naaah! Yet another time you receive a flight ticket and have to calculate how long your flight takes using confusing format that the airlines use to describe the departure/arrival times. But this time, you decide to solve this problem once and for all by writing a program to calculate the flight duration! For simplicity, in the first version of the problem you only handle non-stop flights.

Input

The input contains several test cases. Each test case describes a non-stop flight on a single line of the input. Each flight description begins with flight number (a string of at least 2 at most 7 alphanumeric characters) followed by the departing city name, time zone, and the departure time and also the arriving city name, time zone and the arrival time. City names are strings of at least 1 at most 9 alphanumeric characters.
The time zone is written as a number inside a pair of parentheses with the format shown in the sample input, like (+3.5). Note that the plus/minus sign is always present. This number specifies the offset from the UTC standard time, expressed in hours (so a time in the time zone +3.5 is three hours and half more than the time in UTC). There is no space character between the city names and the time zones.
The flight times are described in the format shown in the sample input, e.g., 4:10a. Note that the time is presented in 12-hour format, the minutes is a two-digit number. A character ‘a’ or ‘p’ immediately follows the time indicating AM and PM times respectively. In case a flight arrives the next day, a ‘+1’ is appended to the arrival time. Assume that no flight takes more than 24 hours (hence we do not have a +2 symbol in arrival times), and there is no test case in which
the flight arrives the day before (hence we do not have a -1 symbol in arrival times).
The end of input is specified by a single line containing a single # character which should not be processed.

Output

For each test case, output a single line containing the flight number, one space character, and the duration of the flight.

The duration must be of form <hours>: <minutes>, where <minutes> is formatted as a two-digit number.

Sample Input

EK976 Tehran(+3.5) 4:10a Dubai(+4) 6:45a
EK432 Dubai(+4) 8:40a Singapore(+8) 7:40p
JL710 Singapore(+8) 11:20p Tokyo(+9) 7:00a+1
EK0215 Dubai(+4) 8:20a LA(-8) 12:50p
#

Sample Output

EK976 2:05
EK432 7:00
JL710 6:40
EK0215 16:30
Submit

Source: Tehran, Asia Region - Regional 2011