It has been 100 years since the first Higgs boson was detected, and particle physics is now a mainstream subject in every high school. Naturally, kids love that they can create tiny black holes with their portable particle accelerators and show them off to their friends. Although even a portable accelerator could in principle create a black hole large enough to swallow the whole planet, the devices are programmed to fire particles only when that catastrophic side effect is impossible.
Your granddaughter is trying to create her own black holes with a portable accelerator kit made of two small particle accelerators, each of which fires one boson-sized particle. Both particles are launched at the same instant, and a black hole appears the moment they collide. She does not know how long she will have to wait for that to happen. Fortunately, each accelerator predicts its particle's trajectory by displaying four integers, called $A$, $B$, $C$, and $D$. Substituting them into
$$r = A t + B$$
$$\theta = C t + D$$
gives the particle's trajectory in polar coordinates: the radius $r$ is measured in distance units and the angle $\theta$ in degrees. Time $t$ is measured in time units and is always a rational value that can be written as an irreducible fraction.
In polar coordinates a point has infinitely many representations. In general, the point $(r, \theta)$ can also be written as $(r,\ \theta \pm k \times 360°)$ or $(-r,\ \theta \pm (2k + 1) \times 180°)$ for any integer $k$. Moreover, the origin ($r = 0$) can be written as $(0, \theta)$ for any $\theta$.
Using the parameters reported by the two accelerators, your granddaughter wants to know whether the particles will ever collide and, if so, when the first collision happens. After the first collision the trajectories can no longer be predicted, so only the first possible collision matters.
She is brilliant and deeply knowledgeable about particle physics, but she cannot program computers, so she is digging through her grandparent's old programming-contest notebook. Luckily for you, there is a note saying you once wrote exactly this program. Now it is time to write it again.
The input consists of several test cases, one per line. Each test case contains eight integers separated by single spaces:
$$A_1\ B_1\ C_1\ D_1\ A_2\ B_2\ C_2\ D_2 \quad (-10^4 \le A_1, B_1, C_1, D_1, A_2, B_2, C_2, D_2 \le 10^4)$$
The first four values ($A_1, B_1, C_1, D_1$) are the parameters shown by the first accelerator, and the last four ($A_2, B_2, C_2, D_2$) are those shown by the second accelerator when both particles are launched.
The input ends with a line of eight zeros ($A_1 = B_1 = C_1 = D_1 = A_2 = B_2 = C_2 = D_2 = 0$), which must not be processed as a test case — those are the values the accelerators would show if launching the particles would create a planet-swallowing black hole. Note that $0$ is otherwise a valid input value; only the line consisting entirely of zeros terminates the input.
For each test case, output a line with two non-negative integers $t_a$ and $t_b$ separated by a single space. If the particles can never collide, print $t_a = t_b = 0$. Otherwise, $t_a / t_b$ must be the earliest collision time written as an irreducible fraction; even when the time is an integer, the denominator must still be printed as $1$.