Result

AC

Duration

3050ms

Code [DL]

x=STDIN.gets_to_end.lines
a=x[0]+"
"
c=x[-1].gsub("K","a"*99)
puts a*~-x.size,c[0..a=~/T/]

stdin

                                        T         
                                                  
                                                  
                                                  
                       K                          

stdout

                                        T         
                                        T         
                                        T         
                                        T         
                       aaaaaaaaaaaaaaaaaa

stderr

strace