Result

AC

Duration

689ms

Code [DL]

a,*b,c=open(0)
i=a.find("T")
x=a
for l in b:x+=a
j=c.find("K")
print(x+" "*j+"K"+"*"*(i-j))

stdin

                          T                       
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
           K                                      

stdout

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

stderr

strace