say $/=get;$!=.index('K'),say $!??.subst('K','R'x$/.index("T")-$!+1)!!$/for lines