eolymp
bolt
Try our new interface for solving problems
Problems

Bicycle Puzzle

Bicycle Puzzle

\includegraphics{https://static.e-olymp.com/content/02/0201d1f57adabf81998a6719775c4f9555868eab.jpg} Per and Gunnar has found a wonderful online bicycle picture puzzle flash solitaire game, and since they are very competitive, they want to find out who is best. The purpose of the game is to descramble a picture of a bicycle. At the start of each game, the picture of the bicycle is cut into \textbf{W} times \textbf{H} equally sized rectangles and scrambled randomly. Then the player repeatedly chooses two arbitrary rectangles and swaps them. He continues to swap rectangles until the picture is complete again. The game keeps track of the number of swaps, which is the score for that particular playthrough. After Gunnar has played a game, he sends his score (along with \textbf{W} and \textbf{H}) to Per, and challenges Per to beat this score. Per soon realizes that if he is unlucky with the scrambling, it is impossible to beat Gunnar's score. Per quickly writes a program to find out the probability that he can beat Gunnar's score (assuming that all scrambled pictures are equally probable) if he plays optimally. But he is not sure whether his program is correct and wants to verify its correctness by challenging you to write the same program. \InputFile The first line of the input consists of a single number \textbf{T} (\textbf{0} < \textbf{T} ≤ \textbf{150}), the number of scenarios. Each scenario is given by a line with three integers \textbf{W }(\textbf{0} < \textbf{W} ≤ \textbf{5}), \textbf{H} (\textbf{0} < \textbf{H} ≤ \textbf{4}) and \textbf{S} (\textbf{0} ≤ \textbf{S} ≤ \textbf{W}·\textbf{H}), where\textbf{ S} is Gunnar's last score. When comparing two scores, the lowest one is best. \OutputFile For each scenario, output a line with the probability that Per beats Gunnar's score. Format the probability as an irreducible fraction where the numerator and the denominator are separated by \textbf{/}. Output only the numerator if the answer is an integer.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3
1 1 1
1 2 1
3 1 2
Output example #1
1
1/2
2/3