sub I{s-^-$"x$_[1]-gem;$/x$_[0].$_.$/} sub D{$~=pop;system($^O=~Win?CLS:"clear"),print, select$Z,$Z,$Z,$~for@_} sub R{$i=0;join$/,map{$j=0;join"",grep!($j++%$_[0]),/./g} grep!($i++%$_[0]),@S} $S=$_=do{local$/;}; y---c>$-and$-=y---cfor@S=/.+/g;$_.=$"x-(y---c-$-)for@S; D(@X=(I(20,41,$_="."),I(20,41,$_=O),I(15,31,$_=R 4), I(13,28,$_=R 3),I(10,20,$_=R 2),$S),.3); D((map{$n=$_;join($/,map($_ x$n,R($_)=~/.+/g),"")x$_}2..4) [0..2,1,0],.2); D$S,join("",map(reverse.$/,@S)),.1for$%..5;D reverse(@X),.3 __DATA__ '''''' ''''''''''' ''''''''''''''' ''''''''''''''''' ''''''''''''''''''' '''''''''''''''''''' ''''''''''''''''''''' ~~~~~~~~~~~~~ ''''''' ''''''''' ~~~~~~~~~~~~~~~~~~~ '''' '''''''' ~~~~~~~~~~~~~~~~~~~~~~~~ ''''''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''''''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '''''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '''''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''' ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''' ~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''' ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''' ~~~~~~~~ ~~~~~~~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