Hide

Problem M
Temporal Turmoil

Old Man Joe runs the busiest saloon in town. Not a second goes by without something happening. Unfortunately one day at exactly 12:00pm (12:00 in 24-hour format) a fight breaks out amongst many of Joe’s patrons. In the midst of the brawl Joe’s prized possession, his late grandfather’s clock, falls off the wall crashing to the ground! Luckily it’s built tough, the mechanical parts remain unscathed, and the clock hands keep rotating continuously. Unluckily the clock’s face isn’t so tough and breaks cleanly off the clock. So clean in fact it’s impossible to tell which orientation the clock was in when it was on the wall. Thinking the clock is a lost cause, Joe decides to ignore it, focusing instead on breaking up the fight; however, this takes quite some time. Fortunately Joe’s wife Lin has a keen eye and has been tracking how many times the hour and minute hands were aligned as well as how many times the minute and second hands were aligned (since the last time the hour and minute hands were aligned). Based off of this information can you help Joe and Lin figure out what time it is, so they can fix their clock?

Input

The first line will contain a single integer $n$, $1 \leq n \leq 10^5$, the number of test cases. The following $n$ lines will each contains two space separated integers $i$ and $j$, $0 \leq i \leq 23$ and $0 \leq j \leq 64$, the number of times the hour and minute hands were aligned and the number of times the minute and second hands were aligned since the last time the hour and minute hands were aligned respectively.

Note: If the minute and hour hands align at the same time that the minute and second hands align this does NOT count towards the minute-second hand alignment count $j$.

Output

For each test case output a single line with the earliest possible time it could be in the format hh:mm:ss (in 24-hour format) padding values with leading 0’s so that each entry is two digits.

Sample Input 1 Sample Output 1
3
1 2
3 5
4 0
13:07:08
15:21:22
16:21:50

Please log in to submit a solution to this problem

Log in