Author: | A. Baranov | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 256 Mb | |
Output file: | Standard output |
The scientists of Flatland have discovered that the universe they live in is topologically similar to the surface of a torus.
This means that along each coordinate axis x and y, the periodicity condition is satisfied with a respective period Lx and Ly.
In other words, points at coordinates (x + u ⋅ Lx, y + v ⋅ Ly) with any integer values u and v are identical.
For the purpose of a scientific experiment, a ray is emitted from a point with coordinates (0, 0), directed by the vector D⃗ = (dx, dy).
It is required to determine the distance the ray will travel before reaching the initial point.
The result should be expressed in units equal to the length of the vector D⃗,
In other words, the task is to find the minimum coefficient λ > 0, such that by shifting the vector, one can reach the initial point.
The obtained number should be represented as an irreducible fraction: λ = αβ.
The beginning of the input data contains a natural numbe n, followed by exactly n queries,
each specified by a set of integers: Lxi, Lyi, dxi и dyi.
The output data should contain the values αi и βi,
obtained in response to each i-th query.
1 ≤ (Lxi, Lyi) ≤ 106, − 106 ≤ (dxi, dyi) ≤ 106,
|dxi| + |dyi| > 0,
1 ≤ n ≤ 105.
No. | Standard input | Standard output |
---|---|---|
1 |
|
|