a=gets;puts a until gets[?K];$_[a=~/T/]=?A;0while$_.sub!'K ','KK';print