시간 제한 | 메모리 제한 | 제출 | 정답 | 맞은 사람 | 정답 비율 |
---|---|---|---|---|---|

1 초 | 128 MB | 2 | 1 | 1 | 50.000% |

It’s been 100 years since the detection of the first Higgs boson and now particle physics is a mainstream subject in all high schools. Obviously, kids love the fact that they can create tiny black holes using only their portable particle accelerators and show off to their friends and colleagues. Although the creation of big black holes that could swallow the whole planet is possible even with these portable particle accelerators, the devices are programmed to only thrown particles when this undesirable side effect is impossible.

Your granddaughter is trying to create her own black holes with a portable accelerator kit, which is composed of two small particle accelerators that throw, each one, a boson-sized particle. Both particles are thrown at the same time, and a black hole appears when the particles collide. However, your granddaughter doesn’t know how much time she’ll have to wait before this happens. Fortunately, each accelerator can predict the particle’s trajectory, showing four integer values into its display, called A, B, C and D. Each value can be replaced into the following equations:

r = At + B

θ = Ct + D

in order to determine the trajectory of the particle, in polar coordinates. The radius (r) is represented in distance units and the angle (θ) in degrees. The time (t) is given in time units and it is always a rational value which can be represented by an irreducible fraction. Your granddaughter knows that in polar coordinates a point has infinite representations. In general, the point (r, θ) can be represented as (r, θ ± k × 360^{o}) or (−r, θ ± (2k + 1) × 180^{o}), where k is any integer. Besides, the origin (r = 0) can be represented as (0, θ) for any θ.

Using these parameters informed by each particle accelerator, your granddaughter wants to determine whether the particles will eventually collide and, if they do, the time when they will collide. After the first collision it is impossible to predict the particle’s trajectory, therefore, only the first possible collision should be considered.

Although your granddaughter is really intelligent and has a deep knowledge of particle physics, she does not know how to program computers and is looking for some notes in her grandfather’s (or grandmother’s) ICPC notebook (don’t forget, she is your granddaughter!). Fortunately for you, there is a note on your notebook which says that you wrote that code during the 2008 ICPC South America Regional Contest (or, to be more specific, this contest).

The input consists of several test cases, one per line. Each test case contains eight integer numbers separated by single spaces, A1, B1, C1, D1, A2, B2, C2, D2 (−104 ≤ A1, B1, C1, D1, A2, B2, C2, D2 ≤ 10^{4}). The first four input values (A1, B1, C1, D1) correspond to the four parameters displayed by the first portable particle accelerator and the following input values (A2, B2, C2, D2) correspond to the four parameters displayed by the second portable particle accelerator when both particles are thrown. The end of the input is represented by A1 = B1 = C1 = D1 = A2 = B2 = C2 = D2 = 0, which should not be processed as a test case, since these are the values displayed by the particle accelerators when a big black hole would be created if the particles were trown. Although the end of input is represented by a line with eight zeroes, note that the number zero is a possible input value.

The input must be read from standard input.

For each test case, your program must output a line containing two non-negative integers ta and tb separated by a single space. If there is no possibility of collision, ta = tb = 0, otherwise, ta/tb must be an irreducible fraction representing the earliest collision time. Even if the fraction results in an integer value, you still must output the number 1 as the denominator (see samples below).

The output must be written to standard output.

1 1 180 0 2 0 180 360 10 10 360 0 -24 18 180 72 5 5 180 0 -12 9 10 40 -9 5 5 180 2 5 5 180 0 0 0 0 0 0 0 0

1 1 0 0 4 17 0 1