map{sub __;$/=$_;sub _;map{$_[$/][$_]{_}=rand(time)%2;push@{$_[$/][$_]{map}},( \$_[_$/][$_]{_}=>\$_[__$/][$_]{_}=>\$_[$/][_$_]{_}=>\$_[$/][__$_]{_},\$_[_$/][ _$_]{_}=>\$_[_$/][__$_]{_}=>\$_[__$/][_$_]{_}=>\$_[__$/][__$_]{_},)}(0..$__)}( 0..($__=(shift||24)-1));sub __{(($-=shift)+1)<=$__?$-+1:0}sub _{(($-=shift)-1) >=0?$--1:$__;}__;__;while(){map{$/=$_;$\="\n";print map{$_[$/][$_]{sub}=$_[$/] [$_]{_}?'*':'.';$.+=$$_ for(@{$_[$/][$_]{map}});$![$/][$_]{_}=$_[$/][$_]{_};$! [$/][$_]{_}=($.==3?1:($.!=2?0:($![$/][$_]{_}==1?1:0)));__;$.=~s _.__;$_[$/][$_ ]{sub};}(0..$__);}(0 .. $__);map{$/=$_;map{$_[$/][$_]{_}=$![$/][$_]{_}}(0..$__ )}(0..$__);_;for(1..4){_;__;}_;sleep 1;}for(1..3){__;_;__;_;_;}__;_;__;_;__;