say $!=get;say m|K|??S|K|{'K'x$!.index('T')-$/.from+1}|!!$! for lines