Result

AC

Duration

850ms

Code [DL]

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

stdin

            T                                     
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
        K                                         

stdout

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

stderr

strace