Under construction

Still being built. Things may change

Time Standards

Interview

Time limit2sMemory limit1024 MB

Summary
Given two time standards that set the hours, minutes, and seconds per unit, convert a moment from the first standard to the same moment in the second.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Statement

Every operating system (including the one Vasya is writing) must handle different time standards correctly.

For example, during the French Revolution, France used decimal time. A day had 10 decimal hours, each decimal hour had 100 decimal minutes, and each decimal minute had 100 decimal seconds.

Nobody knows which time formats will appear in the future, so Vasya wants to support various time standards. A time standard is given by three integers aa, bb, and cc: the number of "hours" in one day, the number of "minutes" in each "hour", and the number of seconds in each "minute". The length of a second and of a day is the same in every standard, but the length of a "minute" and an "hour" may differ.

Two time standards are given. Write a program that converts a time from one standard to the other.

Input

The first line contains three integers a1a_1, b1b_1, and c1c_1, which describe the first time standard. The second line contains a2a_2, b2b_2, and c2c_2 in the same format. The third line contains three numbers h1h_1, m1m_1, and s1s_1, a moment in the first standard, where h1h_1 is the number of "hours", m1m_1 is the number of "minutes", and s1s_1 is the number of seconds (0≤h1<a10 \le h_1 < a_1, 0≤m1<b10 \le m_1 < b_1, 0≤s1<c10 \le s_1 < c_1).

All numbers are non-negative integers not exceeding 1000. It is known that a1⋅b1⋅c1=a2⋅b2⋅c2a_1 \cdot b_1 \cdot c_1 = a_2 \cdot b_2 \cdot c_2.

Output

Print three numbers h2h_2, m2m_2, and s2s_2, the same moment in the second standard, where h2h_2 is the number of "hours", m2m_2 is the number of "minutes", and s2s_2 is the number of seconds (0≤h2<a20 \le h_2 < a_2, 0≤m2<b20 \le m_2 < b_2, 0≤s2<c20 \le s_2 < c_2).

Examples2

  1. Example 1

    Input
    24 60 60
    12 72 100
    11 11 11
    
    Expected output
    5 42 71
    
  2. Example 2

    Input
    2 2 2
    1 1 8
    1 0 1
    
    Expected output
    0 0 5