For this problem, we'll consider a classic puzzle made popular by Sam Loyd, the famous American puzzle author, and recreational mathematician from the early 20th century. Mr. Loyd observed a curious thing regarding the signs commonly used in front of jewelry stores in those days, which resembled big watches. The peculiar fact was that these signs were usually created to represent a certain specific time of the day, some minutes past eight. This seemed to occur invariably, in places all over the world, and during centuries since the creation of mechanical clocks.
If one were asked for an explanation for this phenomenon, it's likely that the idea of symmetry would come up, and the fact that the time represented by these signs place the hour hand and the minute hand at the same distance from the 6. Regardless of the psychological reasons behind it, this provides for a nice mathematical challenge.
The original puzzle made by Sam Loyd asked for the exact time represented by these watches, which had to be some time between 8 o'clock and 8:30. However, with the aid of computational resources, it should not be much harder to solve this in general for all hours around the clock, and using any arbitrary hour for the symmetry line.
Write a program that helps you with this extended puzzle. You are presented with an hour hand showing a certain time of the day, which determines the symmetry line, and a range of time (a starting and ending time). Your task is to print all occurrences within that range of time (inclusive) when the hour hand and the minute hand are on opposite sides of the symmetry line, and at the same distance from it.
Input
Input starts with an integer T (≤ 20000), denoting the number of test cases.
Each test case starts with three time representations in theform HH:MM:SS
. The first of these is the hour hand time showing thesymmetry line, the second of them is the starting time, and the last one is theending time, and it is guaranteed that the starting time doesn't comechronologically after the ending time. The times are separated by single spaces.You may assume that 0 ≤ HH < 12, 0 ≤ MM, SS < 60.
As you may have noticed, for simplicity, the hour 12 will bereplaced by hour zero.
Output
For each case, print the case number and the number of answers for the case in a single line. Then print all answers in chronological order, each one in its own line.
Always use 2 digits to represent the amount of hours, minutes, and the integer part of the seconds. To avoid accuracy problems, if the number of seconds is not an exact integer, then it has to be printed as a mixed number with its fractional part in the form p/q, where p and q are coprimes. See the samples below for more details.
As in the input, in the output you should not use hour 12, but hour zero instead.
Sample
Sample Input | Sample Output |
---|---|
5 06:00:00 08:00:00 09:00:00 06:00:00 00:00:00 00:45:15 09:33:41 02:18:27 03:20:13 01:00:00 01:18:27 02:00:00 09:30:00 03:44:17 05:00:57 | Case 1: 1 08:18:27 9/13 Case 2: 1 00:00:00 Case 3: 2 02:23:38 8/13 03:19:01 9/13 Case 4: 1 02:00:00 Case 5: 1 04:13:50 10/13 |
Notes
- Be careful about the 4th test case, for the resulting time - 02:00:00, there is no trailing space.
- For the 5th case, the red hour hand showing in the picture determines the symmetry line.