Woburn Challenge 2002
The Head-Monkey is a brilliant tactician, and what's more, she is
brilliant at having her troops prepared for battle. This time the battle
is for all the proverbial marbles. The Head-Monkey addresses her legion
and says: "My fellow monkeys, this battle is for all the marbles!", to
which Tiny responds, "Umm, no offence, do we get marbles if we win,
Sir?!" After this issue is dealt with, the Head-Monkey decides it's time
for the monkeys to prepare themselves for battle. The Head-Monkey is
quite a pacifist, and firmly believes in brains before brawn. Confident
of the fact that no matter how difficult the final battle is, her monkeys
will end up victorious if their minds are sharp, she poses the following
problem: Given two fractions and
find the fraction
between
and
(i.e.
) that has the smallest denominator
(i.e.
is minimum). If there is more than one such fraction, output the
smallest one.
Constraints
and
will have no common factors.
and
will have no common factors.
BONUS: For the truly nerdy monkeys, the Head-Monkey has agreed to
give a bonus (i.e., this problem will count as problems solved) if
the problem is solved for larger constraints: namely,
,
,
and
up
to
.
Input Specification
The first line contains a single integer,
,
indicating the number of test cases.
Each test case consists of a single line containing four integers
separated by a space, namely ,
,
and
. (These correspond to
and
)
Output Specification
For each test case, output the fraction that satisfies the above
criteria, in the format m/n
. Remember, and
must not have any factors
in common.
Sample Input
2
1 3 2 3
1 5 2 5
Sample Output
1/2
1/3
Comments