#!perl -ln0 $:='((?=W|.{9}W)|(?<=W.)|(?<=W.{10}))';{1while s/w$:/W/s;/ $:/gs>//gs&&print+("@-E-1"+1)=~y/./ /r;y/W/x/;s/w/W/&&redo}