V=20:screen ,200,400:title "0":dim B,4:dim C,10,V:dim D,10,V:randomize:F=2:boxf
dim A,4,7:A=1,4,5,6,5,6,10,14,5,6,9,13,5,6,9,10,2,6,5,9,1,5,6,10,1,5,9,13:repeat
wait 1:if G=0{rnd N,7:memcpy B,A,16,,16*N:H=3:I=-4:J=0:G=1}J-F:if J<0{K=0:L=1
gosub Z:if M=0{N=0:repeat 4:O=B.cnt\4+H:P=B.cnt/4+I:if P<0{N=1:break}C.O.P=1
loop:if N{break}dim Q,V:R=0:repeat V:S=cnt:N=0:repeat 10:N+=C.cnt.S:loop:if N>9{
Q.cnt=1:R+:palcolor 255:boxf 0,cnt*V,200,cnt*V+18}loop:if R>0{wait 50:color:boxf
E+R*R:title ""+E:N=19:repeat V:S=19-cnt:if Q.S=0{memcpy C,C,40,N*40,S*40:N-}loop
memset C,,N*40}G=0}J=100}stick T,8,1:K=T&4!0+(T&1!0*-1):L=T&8!0:gosub Z:if T&16{
dim U,4:memcpy U,B,16:repeat 4:N=B.cnt\4:B.cnt=N*4+3-(B.cnt/4):loop:K=0:L=0
gosub Z:if M=0{memcpy B,U,16:gosub Z}}redraw 0:repeat V:S=cnt:repeat 10:K=cnt*V
palcolor D.cnt.S*9:L=S*V:boxf K,L,K+18,L+18:loop:loop:redraw:loop:dialog "over"
end:*Z:M=1:repeat 4:O=B.cnt\4+H+K:P=B.cnt/4+I+L:if (P>19)|(O<0)|(O>9):M=0:break
if P<0{continue}if C.O.P=1{M=0}loop:if M=0{return}memcpy D,C,10*V*4:H+K:I+L
repeat 4:O=B.cnt\4+H:P=B.cnt/4+I:if P>=0{D.O.P=1}loop:return