Fax McClad, Croneria's hungriest bounty hunter, wants to cook a quick meal in his microwave. Unfortunately, some of the buttons on his microwave have broken down.
Fax wants to microwave his food for
hh is a 2 digit number representing the number of hours,
mm is a 2 digit number representing minutes, and
ss is a 2 digit number representing seconds. Note that
ss do not necessarily have to be less than .
For reference, there are seconds in a minute, and seconds in an hour.
The list of usable buttons will be given in a string as input. There will be at least one usable button.
Can you tell Fax the closest time that can be inputted to his desired time? That is, tell him the time with the smallest time difference that can be inputted in the microwave. Note that all digits (including zeroes) of the inputted time must be present in the string of working buttons.
The first line of input will contain Fax's desired time in the form
The second line of input will contain a string of at least character and up to characters, consisting of unique digits through in order. A digit in the string means that the corresponding button is working.
Output the closest time in
hh:mm:ss format that can be inputted in the microwave to Fax's desired time.
If there is more than one answer, output any of them.
Sample Input 1
Sample Output 1
Explanation for Sample Output 1
Fax wants to microwave his food for seconds. All of the buttons on the microwave work, except for
A second difference is the best difference possible. For example, all of the digits in
01:16:86 are allowed, and this time results in seconds. Another possible answer is
Sample Input 2
Sample Output 2