@{::}{p,l,k,d,g,t}=(sub{print"\n @{[reverse @t[7..12]]}\n$t[13]\t\t$t[6] @t[0..5]\n\nplayer",$_[0]+1," (@{[l($_[0])]}):"},sub{map{1+$_-$_[0]*7}grep{$t[$_]}map{$_+$_[0]*7}0..5}, sub{do{$p=<>;$p=int$p}while!grep{$p==$_}l($_[0]);$p}, sub{print"player ",$u+1," looses\n"},sub{ $_[1]+=$_[0]*7;$l=0;$n=$t[$_[1]-1];$t[$_[1]-1]=0;while($n){$_[1]%=14;unless($_[1]==6+(1-$_[0])*7){$t[$l=$_[1]]++;$n--}$_[1]++};return 1 if($l==6)or($l==13); if(($l>0+$_[0]*7)and($l<=5+$_[0]*7)and($t[$l]==1)and($t[($l+7)%14]!=0)){$t[$l]=0;$t[6+$_[0]*7]+=$t[($l+7)%14]+1;$t[($l+7)%14]=0} },sub{p($_[0])&&g($_[0],k($_[0]))});($p,$u,@t)=(0,1,map{6}1..14);@t[6,13]=(0,0); while(1){$u=1-$u;$_=1;do{d($u)&&last if!l($u)&&$_}while$_=t($u);d($u)&&last if$t[6+7*$u]>36;}