#B4231. Calculate Sleep Duration

    ID: 11888 Type: Default 1000ms 256MiB

Calculate Sleep Duration

Calculate Sleep Duration

Little X sets his alarm to a specific time \(h_1:m_1:s_1\) in 24-hour format and then goes to sleep immediately. Since he is extremely exhausted, he will not wake up until the alarm rings. Given the time \(h_2:m_2:s_2\) when he falls asleep, calculate the duration he sleeps until the alarm rings. Note that the alarm rings every day, and when a new day starts, the clock resets to \(00:00:00\).

The duration is defined as follows:

[ \text{duration} = \begin{cases} , ; (h_1 \times 3600 + m_1 \times 60 + s_1) - (h_2 \times 3600 + m_2 \times 60 + s_2), & \text{if } (h_2:m_2:s_2) < (h_1:m_1:s_1), \ 86400 - (h_2 \times 3600 + m_2 \times 60 + s_2) + (h_1 \times 3600 + m_1 \times 60 + s_1), & \text{otherwise.} \end{cases} ]

If the falling asleep time is exactly the same as the alarm time, the alarm will ring on the next day, i.e. after 24 hours.

inputFormat

The input consists of two lines:

  • The first line contains three integers \(h_1\), \(m_1\), and \(s_1\) (0 ≤ \(h_1\) < 24, 0 ≤ \(m_1, s_1\) < 60), representing the alarm time.
  • The second line contains three integers \(h_2\), \(m_2\), and \(s_2\) (0 ≤ \(h_2\) < 24, 0 ≤ \(m_2, s_2\) < 60), representing the time when Little X falls asleep.

outputFormat

Output three integers separated by spaces representing the duration (in hours, minutes, and seconds) that Little X sleeps.

sample

7 0 0
6 0 0
1 0 0