URI Online Judge | 2462


By OBI - Olimpíada Brasileira de Informática 2014 BR Brazil

Timelimit: 1

João was browsing the internet, looking flight schedules of various airlines between different cities, and noticed that in some cases direct flights between two cities had different times depending on whether they were flight onward or return.

The only possible explanation was to flights connecting cities located in different time zones. João then came to the conclusion that it would be possible to determine the difference in time zones, based only on schedules provided by the airlines.

For example, a flight out of the Haquérnia at 10:00 am and arrives in Nerdínia 22:00 hours, while another flight out of Nerdínia at 10:00 am and arrives in Haquérnia to 18:00. What is the explanation? Note that both flights using the same aircraft on the same route, a round, another back. In reality, the flight lasts 10 hours and Nerdínia is in a zone +2 hours hours ahead of time zone Haquérnia (hence the Haquérnia time zone is -2 hours ahead of time zone Nerdínia).

João then noticed the time table of several airlines, but made a mistake. He forgot to write down dates of departure and arrival. For example, if the departure of the flight is at 18:00 and arrival is at 14:00, João can not tell if the arrival date is the following the departure in flight that lasts 20 hours, between cities in the same time zone, or if the arrival date is the same as starting with a flight time of one hour, the destination city is in time zone five hours behind the time zone of the city origin.

Your task is to help João to determine the flight time and the difference between the time zones of arrival and departure of each pair of flights with table, a round another back, even without knowing the dates of the flights.


The entry consists of only one line, with four times separated by a space. These times involve flights between two cities, A and B are, respectively, pA, cB, pB and cA. The pA time indicates the departure time of a flight from A to B, local time of A. The time indicates the arrival time of the flight even in town B, local time of B. The time is the starting time flight back from B to A, local time B. cA time is the arrival time of the flight back, local time of A.


The output consists of one line, informing the flight time in minutes and how many hours B is ahead of A, in terms of time zones. The two values must be separated by a blank space.

Input Sample Output Sample

10:00 22:00 10:00 18:00

600 2

17:00 23:00 17:00 13:00

60 5

10:00 18:00 10:00 22:00

600 -2

17:00 13:00 17:00 23:00

60 -5

18:00 12:00 18:00 14:00

420 11

18:00 14:00 18:00 12:00

420 -11