($a)=@ARGV;$a||=10;$b=40;$d='.';$c=($b-$a);$f=($c/2);$g=0;$j=5;$e=1;$h=$f;foreach(0..$c){$i[$_]=(100/$c)*$_}while($j){@k=();if($h<$f){$h=$f;$j--;$e=-$e}elsif($h>=($f+$a)){$h=$f+$a-1;$j--;$e=-$e}$|=1;@l=(' ')x$a;$l[$h-($f)]=$d;push @k,'*'x($f+1);push @k,@l;push @k,'*'x($c-$f+1);push @k,' ',$j;print join('',(@k));if(rand(100)<=$i[$f]){$f--;}else{$f++}$g++;$y=$x='';vec($x,fileno(STDIN),1)=1;if(select($y=$x,undef,undef,.1)){until(sysread(STDIN,$b,1)){}$e=-$e;}else{print"\n"}$h+=$e}print"$g\n";