x z x :x s/$/%;%90123456789/ :y s/(.)%((%?.)*\1)|;.*/\3\2/ ty /\n/bz s/^0*// N :z /\n0+$/!{ x N x bx } s/(.*)\n.*/,\1;/ x s/^\n// s/(\n|$)/%&/g s/(^|\n)/:/g :a /[0-9]%/{ s/ %/ 0%/g s/^/0@1@2@3@4@5@6@7@8@9@#/ :b s/([0-9])@([^#]*#.*)(:[^:]*)\1%([^:]*)/\1@\3%\1\4\2/ tb s/.@|#//g ba } s/%0*([0-9])/\1/g /;/be s/^/:0 0:,0;/ :c :d s/(,([0-9]*);.*:)(_?[0-9]* )?\2 ([^:]*)/\1_\2 \3\4/ td /\n/bf s/:_[0-9]* _[^:]*//g s/(^[^;]*)(;[^_]*)(:_[0-9]* ([0-9]*)[^:]*)/\3\1,\4\2/ s/^:_([0-9]*) ([^:,]*)([^;]*)(:\1 [0-9]*)/:_\2%\4%\3/ ba :e /^:_/s/^(:_[0-9]* )[^:]*(:[0-9]* ([0-9]*))/\1\3\2/ s/:_(.*;)/:\1/ s/%//g tc s/_|,.*//g x G bd :f s/.*:_[^ ] ([0-9]*).*/\1/ tg s/.*// :g