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 :

0 ≤  hh < 24

0 ≤ mm < 60

0 ≤  ss  < 60

SAMPLE INPUT
3
00:00:00
12:59:59
23:59:59

SAMPLE OUTPUT
01:23:45
13:02:45
01:23:45
import sys                                                                                                                                                                         
                                                                                                                                                                                   
class date:                                                                                                                                                                        
    def __init__(self, str_date):                                                                                                                                                  
        self.hour=int(str_date[0:2])                                                                                                                                               
        self.mnts=int(str_date[3:5])                                                                                                                                               
        self.secs=int(str_date[6:8])                                                                                                                                               
    def bump(self):                                                                                                                                                                
        self.secs=self.secs+1                                                                                                                                                      
        if self.secs==60:                                                                                                                                                          
            self.secs=0                                                                                                                                                            
            self.mnts=self.mnts+1                                                                                                                                                  
        if self.mnts==60:                                                                                                                                                          
            self.mnts=0                                                                                                                                                            
            self.hour=self.hour+1                                                                                                                                                  
        if self.hour==24:                                                                                                                                                          
            self.hour=0                                                                                                                                                            
    def out(self):                                                                                                                                                                 
        return "%02d:%02d:%02d" % (self.hour, self.mnts, self.secs)                                                                                                                
    def isLucky(self):                                                                                                                                                             
        str_date="%02d%02d%02d" % (self.hour, self.mnts, self.secs)                                                                                                                
        list_date=set([x for x in str_date])                                                                                                                                       
        if len(list_date) == 6:                                                                                                                                                    
            return True                                                                                                                                                            
        else:                                                                                                                                                                      
            return False                                                                                                                                                           
    def getLucky(self):                                                                                                                                                            
        while not self.isLucky():                                                                                                                                                  
            o.bump()                                                                                                                                                               
                                                                                                                                                                                   
t=int(raw_input())                                                                                                                                                              
for i in range(0, t):       
    o=date(raw_input())                                                                                                                                                                   
    o.getLucky()                                                                                                                                                                   
    print o.out()