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