Clocks

In woodwork class in school, Mouse Stofl's friend Mouse Nikola has crafted a wall clock with a 24-hours-clock-face, an electric motor and many cog wheels. He enjoyed it a lot. Because he likes cats, he has painted many cats on the clock-face. However, when he set the clock and inserted the battery, he realized that his clock does not run with the correct speed. He must have accidentally interchanged a few cog wheels! At least, the clock runs in the correct direction (clock-wise rotation), and always at the same speed.

First Mouse Nikola was very disappointed. However, he realized quickly that he can still use the clock. He just needs to know the correct time and the time his clock shows at two given points in time. Then he can always determine the correct time given the time of his clock. In order to avoid always having to calculate the correct time in his head, he would like to write a program that shows him the correct time when he enters the time his clock shows.

For example, Nikola's clock shows 15:00 at 12 o'clock. Two hours later he again checks the time on his clock and it shows 20:00. From now on he is able to determine the correct time given the time on his clock. If his clock now shows 6 o'clock, he knows that in reality it is 18:00.

Input

The input contains three lines. The first two lines stand for a point in time each and contain two integers, the correct time and the time of Nikola's clock in minutes. Both comparisons of the clocks are made on day 0. Hence, all four times $t_i$ ($0 \leq t_i < 1440$) are measured before day 0 is over (so before 24 hours passed) on either of the two clocks (Nikola's or the correct clock). Moreover for neither clock do the two times coincide. That is, the two given times on the correct clock are not equal and the two given times on Nikola's clock are not equal, either. The third line contains two integers $d$ and $t$ ($0 \leq d \leq 10$, $0 \leq t < 1440$). $d$ indicates the number of days that passed since day 0 according to Nikola's clock. $t$ indicates the time in minutes on Nikola's clock on day $d$. All numbers on the same lines are separated by single spaces.

Output

Output one line with three integers $h$, $m$ and $s$ ($0 \leq h < 24$, $0 \leq m,s < 60$) separated by single spaces, the correct time which would be shown by a correct clock. The first integer describes the hour, the second the minutes and the third the seconds. If the result also contains parts of a second, it should be rounded mathematically to full seconds.

Example 1

InputOutput

720 720
750 775
5 0

22 54 33

Example 2

InputOutput

510 511
630 636
1 10

23 31 26

Explanation of Example 1

At 12:00 (720 minutes), both clocks display the same time. 30 minutes on the real clock after, Nikola's clock already displays 12:55, instead of 12:30. That is, Nikola's clock runs at almost twice (1.8333…, to be exact) the speed of the real clock. The point in time we ask for is when Nikola's clock is at day 5, that is, when Nikola's clock has been running for 120 hours (5*24). We know that at 12:00 on the first day both clocks show the same time. From then on, Nikola's clock keeps on running for 108 hours (120-12). But those 108 hours are measured at a speed of 1.83333.. and those correspond to only 58.9090… real time hours. We add the 12 hours of the first day, and conclude that the time we look for is at 70.9090.. hours, or to put it differently: 2 Days 22 Hours 54 Minutes and 32.73.. Seconds.

We round the 32.73 Seconds mathematically (here rounding up) to 33 and get the result.

Changes

  • October 4: Clarification given that times do not coincide.
  • October 12: Explanation of example 1 added
  • November 25: Example 2 added (after request)

Submission