10 poke 53280,6: poke 53281,0
20 print chr$(31) chr$(147)
30 dim H(4,3,2,2), G(3,3)
40 dim C(1039), P(999), Q(3)
50 dim A(370), X(370), Y(370)
60 dim E(255), B(11), K(2), N(1)
70 dim D(3), S(3), I(3)
80 dim V(3), W(3), T(3)
100 B(10)=38: B(11)=-38
110 E(157)=1: E(17)=2: E(145)=3
120 G(0,1)=2: G(1,0)=2: G(1,3)=1
130 G(2,1)=3: G(3,0)=3: G(3,2)=1
140 for n=0 to 3: read I(n),T(n): next
150 for n=0 to 3: read V(n),W(n): next
160 for n=0 to 3: read D(n),S(n): next
180 for v=0 to 4
190 for w=0 to 3: read E$: n=0
200 for y=0 to 2
210 for x=0 to 2: n=n+1
220 H(v,w,y,x)=asc(mid$(E$,n))-48
230 next x,y,w,v
250 for y=0 to 24: read E$
260 for x=1 to 40
270 v=0: w=224: a=asc(mid$(E$,x))
280 on a-44 goto 310,320,350,340
290 e=e+1: A(e)=a-49: C(c)=e
300 X(e)=x: Y(e)=y: goto 340
310 w=182
320 v=1: w=w-101: C(c)=-w
330 P(c-1)=c: P(c+39)=c: P(c+40)=c
340 poke 55296+c,v
350 poke 1024+c,w
360 c=c+1
370 next x,y
380 c=739
400 for n=0 to 3
410 e=S(n): a=A(C(e)): t=T(n)
420 if a>8 goto 500
430 if e=425 then T(n)=n+2
440 if a<4 then D(n)=G(a,D(n)): goto 500
450 x=X(C(e)): y=Y(C(e))
460 if t=1 then x=x-20: y=y-7: goto 490
470 x=X(b)-x: y=Y(b)-y
480 if t<6 then x=x*V(n): y=y*W(n)
490 D(n)=H(a-4,D(n),sgn(y)+1,sgn(x)+1)
500 f=e+I(D(n)): if C(f)=0 then f=e+B(a)
520 poke 55296+e,0: poke 55297+e,0
530 poke 55256+e,0: poke 55257+e,0
540 S(n)=f: v=P(e)
550 if v then poke 1024+v,-C(v): poke 55296+v,1
560 if P(f) then poke 1024+P(f),224
570 poke 55296+f,t: poke 55297+f,t
580 poke 55256+f,t: poke 55257+f,t
600 if e=c or f=c then T(n)=1: if t=n+2 goto 600
650 next
700 n=0: get E$: if E$="" goto 720
710 N(0)=asc(E$): goto 700
720 f=c+I(E(N(n))): if C(f)>0 goto 760
740 if n=0 then n=1: goto 720
750 f=c+B(A(b)): if c=f goto 790
760 poke 55296+c,0: poke 55297+c,0
770 poke 55256+c,0: poke 55257+c,0
780 c=f: b=C(f): N(1)=N(n)
790 poke 55296+f,7: poke 55297+f,7
800 poke 55256+f,7: poke 55257+f,7
810 v=P(c): if v=0 goto 400
820 poke 1024+v,224
840 P(v-1)=0: P(v+39)=0: P(v+40)=0
850 if C(v)+123 then for n=0 to 3: T(n)=11: next
860 goto 400
1000 data 1,2,-1,3,40,4,-40,5
1010 data -1,-1,-1,1,1,-1,1,1
1020 data 0,414,1,424,1,494,0,504
1100 data "000000000","222222333"
1110 data "022022022","033033033"
1120 data "222222333","000000000"
1130 data "221221221","331331331"
1140 data "222000000","222111111"
1150 data "000000000","001001001"
1160 data "000000333","111111333"
1170 data "001001001","000000000"
1180 data "222000333","222111333"
1190 data "021021021","031031031"
1200 data "0.0.0.0.0.0.0.0.0.////0.0.0.0.0.0.0.0.0."
1210 data "1:::::7:::::::::20////1:::::::::7:::::20"
1220 data ":0////:0////////:0////:0////////:0////:0"
1230 data ":.0.0.:.0.0.0.0.:.0.0.:.0.0.0.0.:.0.0.:."
1240 data "5:::::8:::::::::9:::::9:::::::::8:::::60"
1250 data ":0//////////////:0////:0//////////////:0"
1260 data ":-0.0.0.//000000:00000:0000000//0.0.0.:-"
1270 data "3:::::20//1:::::8:2:1:8:::::20//1:::::40"
1280 data "//////:.//:0//////:0:0//////:0//:.//////"
1290 data "//////:0//:0/00000:0:000000/:0//:0//////"
1300 data "000000:.00:0/1::::4:3::::20/:000:.000000"
1310 data ";:::::9:::60/:00000000000:0/5:::9:::::<0"
1320 data "//////:.//:0/3:::::::::::40/:0//:.//////"
1330 data "//////:0//:0////////////////:0//:0//////"
1340 data "0.0.0.:.//:0000000////000000:0//:.0.0.0."
1350 data "1:::::60//3:::::20////1:::::40//5:::::20"
1360 data ":0////:0////////:0////:0////////:0////:0"
1370 data ":-0.0.:.0.0.0.0.:.0000:.0.0.0.0.:.0.0.:-"
1380 data "3:::::9:::7:::::8:::::8:::::7:::9:::::40"
1390 data "//////:0//:0////////////////:0//:0//////"
1400 data "0.0.0.:.//:.0.0.0.////0.0.0.:.//:.0.0.0."
1410 data "1:::::40//3:::::20////1:::::40//3:::::20"
1430 data ":0//////////////:0////:0//////////////:0"
1440 data ":.0.0.0.0.0.0.0.:.0.0.:.0.0.0.0.0.0.0.:."
1450 data "3:::::::::::::::8:::::8:::::::::::::::40"