Result

AC

Duration

880ms

Code [DL]

import std.stdio;void main(){
int b=0;char[] c,d,e;for(c=readln.dup;e=readln.dup,e;d=e)write(c);
for(;d[++b]-75;){};
for(;c[b]-84;)++c[b++];write(c);
}

stdin

                 T                                
                                                  
              K                                   

stdout

                 T                                
                 T                                
              !!!T                                

stderr

strace