Result

WA

Duration

849ms

Code [DL]

a,*b,c=open(0)
i=a.find("T")
x=a*3
d=c.rstrip()+"*"*i
print(x+d[:i+1])

stdin

                                        T         
                                                  
                                                  
                                                  
                   K                              

stdout

                                        T         
                                        T         
                                        T         
                   K*********************

stderr

strace