/(\pl)(?{++$$1})(.)(?{$l{$1}=$2;--$$2})^/ for<>; @c=grep$$_>1,A..Z; exit!print-1if$#c; for($_="@c";$_;){ print; $_=$l{$_}; }