Tim tells the time in his own way. Ask him and he might answer 20 after 8, which sounds ordinary, or 90 after 8 and 126 til 4, which do not.
Tim's rule is this. 20 after 8 is the first time after 8 o'clock at which the hour hand and the minute hand make an angle of 20 degrees. 126 til 4 is the time closest to 4 o'clock among the times before 4 o'clock at which the two hands make an angle of 126 degrees.
Both hands move continuously at a constant speed. Write a program that converts Tim's phrases into ordinary times.
The first line has the number of test cases n. Each of the next n lines holds one string of the form a after b or a til b, where a and b are integers with 0≤a<360 and 1≤b≤12.
The angle is measured starting at the hour hand and moving clockwise until reaching the minute hand. At 9 o'clock the hands make an angle of 90 degrees, and at 3 o'clock they make an angle of 270 degrees.
after means only a time later than b o'clock, and til means only a time earlier than b o'clock. If the angle is already a degrees at b o'clock, that exact moment is not an answer.
For each test case print one line of the form Case i: h:m:s, where i is the test case number starting at 1, and h, m and s are the hour, the minute and the second closest to the time you found.
The hour satisfies 1≤h≤12 and is printed without padding. Always print two digits for the minute and two digits for the second.