MultistringRewriteStep[rule_Rule,state_List]/;Length[First[rule]]==Length[Last[rule]]:=Block[{canonicalisedState,lhs,rhs,lhsRhs,stringPermutations,matchPositions,generatedEvents},canonicalisedState=Sort@state;lhs=First[rule];rhs=Last[rule];lhsRhs=Transpose[{lhs,rhs}];stringPermutations=Permutations[MapIndexed[{First[#2],#1}&,canonicalisedState],{Length[First[rule]]}];matchPositions=Select[MapThread[{#1,Rule@@#2}->StringPosition[Last[#1],First[#2]]&,{#,lhsRhs}]&/@stringPermutations,AllTrue[#,(Length[Last[#]]>0&)]&];matchPositions=SortBy[#,#[[1,1,1]]&]&/@matchPositions;generatedEvents=Catenate[Block[{match=#,positionIndices,events},positionIndices=CartesianProduct@@(Range[Length[Last[#]]]&/@match);events=(positionIndex|->MapIndexed[First[#1]->Last[#1][[First@positionIndex[[#2]]]]&,match])/@positionIndices;DirectedEdge[canonicalisedState,Sort@Fold[Block[{strs=#1,event=#2,rewritePosition,rewrite,stringPosition},rewritePosition=event[[1,1,1]];rewrite=event[[1,-1]];stringPosition=event[[-1]];ReplacePart[strs,rewritePosition->StringReplacePart[strs[[rewritePosition]],Last[rewrite],stringPosition]]]&,canonicalisedState,#],#]&/@events]&/@matchPositions];generatedEvents]