In Puzzleland (IV)

While Whittington is busy with his cat, the small boy asks the princess: if it takes six seconds for the clock to strike six, how long would it take to strike twelve? Every hour the tower clock sounds a large bell as many times as the number of hours it is marking. So, for example, at 6 o’clock it sounds the bell six times. The time it takes to complete this task is counted from the moment it hits the bell the frst time until the moment it hits it the last time. The time between consecutive strikes is always constant. You know that at hour H1 it takes the clock exactly S sec- onds to strike H1. How long would it take to strike a diferent hour H2? Input To the right: London tower’s clock Input starts with a positive integer T, that denotes the number of test cases. Each test case is described by three integer numbers in a single line, in order: H1, S, H2. T ≤5000;2≤H1,H2≤12;0<S<60;H1̸=H2 Output For each test case, print the case number, followed by the exact number of seconds that the clock takes to mark H2. If this number is not an integer, and is less than 1, then print it as a simplifed fraction p/q (that is, p and q have to be coprimes). If the answer is not an integer, and is greater than 1, then print it as a mixed number, with its fraction part simplifed. See the samples below for the formatting details. Sample Input 3 6 6 12 6 6 11 312 Sample Output Case 1: 13 1/5 Case 2: 12 Case 3: 1/2