Lucky Time

4.7

6 votes
Implementation, Data Structures, Ad-Hoc, Easy, Open, Approved
Problem

Alice is a geeky girl. She has a lot of codes to execute but she always choose a lucky time to execute a code.

  • Time is shown in 24 hour format as hh:mm:ss
  • Time is said to be lucky if all the 6 characters (except ':') are different.

Given the time when she completed the code find a lucky time to execute it so that Alice need to wait as little as possible.

Input :

First line contains T, the number of test cases. Each of next T lines contains time when she completes a code (in format described above).

Output:

For each test case, output a single line containing lucky time (in format described above)

Constraints :

0hh<24

0mm<60

0ss<60

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?