Context-Free Clock

Time limit1sMemory limit128 MB

Problem

A round wall clock with no orientation markings

You recently installed a stylish, perfectly round clock in your office. It has no markings that identify its orientation, so after you accidentally bumped it you realized that 12 o'clock may no longer be at the top. Even so, you would still like to figure out what time it is.

Luckily, you just overheard a coworker say the time, and you have a protractor, so you can measure the angle between the hour and minute hands.

Your program must print the first time, on or after the overheard time, at which the angle between the hour and minute hands matches the measured angle. The angle (an integer from 0 to 359 degrees, inclusive) is measured clockwise from the hour hand to the minute hand. Assume both hands move smoothly and continuously.

Input

Each line contains one test case of the form

A HH:MM:SS

where A is the integer number of degrees you must travel clockwise to get from the hour hand to the minute hand, and HH:MM:SS is the overheard time in 24-hour form. The bounds are $0 \le A \le 359$, $0 \le HH \le 23$, $0 \le MM \le 59$, and $0 \le SS \le 59$. HH, MM, and SS are always exactly two digits, zero-padded if necessary.

The input ends with the line

-1 00:00:00

which must not be processed.

Output

For each test case, print one line of the form

HH:MM:SS

giving the first time, on or after the input time, at which the clockwise angle from the hour hand to the minute hand is exactly A degrees, rounded down to the nearest second. Zero-pad HH, MM, and SS to two digits, with HH in $0 \ldots 23$, MM in $0 \ldots 59$, and SS in $0 \ldots 59$. If that instant falls in the following day, express it within the same 24-hour day (i.e. modulo 24:00:00).