10 poke 53280,6: poke 53281,0
20 print chr$(31) chr$(147)
30 dim H(4,3,2,2), M(11,4,3), G(3,3)
40 dim C(1039), P(999), E(255)
50 dim A(370), X(370), Y(370)
60 dim B(11), J(3,1), K(3,1)
70 dim F(39), Q(15), N(1)
80 dim D(3), S(3), I(3)
90 dim V(3), W(4), T(3)
100 G(0,1)=2: G(1,0)=2: G(1,3)=1
110 G(2,1)=3: G(3,0)=3: G(3,2)=1
120 E(157)=1: E(17)=2: E(145)=3
130 Q(15)=5: B(10)=38: B(11)=-38
140 for n=0 to 5: read Q(n+5): next
150 for n=0 to 3: read I(n),T(n): next
160 for n=0 to 3: read V(n),W(n): next
170 for n=0 to 3: read D(n),S(n): next
180 for v=0 to 2 step 2
190 for w=0 to 1: read J(v,w),K(v,w)
200 J(v+1,w)=K(v,w): K(v+1,w)=J(v,w)
210 next w,v
220 for v=0 to 4
230 for w=0 to 3: read E$: n=0: m=v=w
240 M(11,v,w)=1+m: if W(v)=W(w) goto 270
250 for t=2 to 5: M(t,v,w)=2: next
270 for y=0 to 2
280 for x=0 to 2: n=n+1
290 H(v,w,y,x)=asc(mid$(E$,n))-48
300 next x,y,w,v
310 for y=0 to 24: read E$: e=0: m=41
320 for x=0 to 19
330 F(x)=asc(mid$(E$,x+1))-44
340 e=e=0: m=m+e+e: n=Q(F(x))
350 if n then F(m-1)=9+n: n=sgn(n)
360 F(m+e)=F(x)+n
370 next
380 for x=0 to 39
390 v=0: w=224
400 if P(c) then v=1: w=P(c)
410 on F(x) goto 440,450,480,470
420 d=d+1: A(d)=F(x)-5: C(c)=d
430 X(d)=x: Y(d)=y: goto 470
440 P(c+1)=123: P(c+40)=124: P(c+41)=126
450 v=1: w=w-116
460 C(c)=1-F(x): P(c)=w
470 poke 55296+c,v
480 poke 1024+c,w: c=c+1
490 next x,y
500 poke 1424,96: poke 1463,96
510 poke 1464,96: poke 1503,96
520 C(300)=d+1: c=739
550 for m=0 to 3
560 for n=0 to 3
570 t=T(n): on M(t,m,n) goto 770,780
580 e=S(n): if e=c then T(n)=1: if t=n+2 goto 580
590 a=C(e): d=D(n): if A(a)>8 goto 660
600 if e=425 then T(n)=n+2
610 if A(a)<4 then d=G(A(a),d): goto 660
620 if t=1 then x=X(a)-20: y=Y(a)-7: goto 650
630 x=X(b)-X(a): y=Y(b)-Y(a)
640 if t<6 then x=x*V(n): y=y*W(n)
650 d=H(A(a)-4,d,sgn(y)+1,sgn(x)+1)
660 D(n)=d: S(n)=e+I(d)
670 if C(S(n))=0 then S(n)=e+B(A(a))
690 for v=0 to 1
700 w=e-J(d,v): y=0
710 if P(w) then poke 1024+w,P(w): y=1
720 poke 55296+w,y
730 w=S(n)-K(d,v)
740 poke 55296+w,t
750 if P(w) then poke 1024+w,224
760 next
770 if S(n)=c then T(n)=1: if t=n+2 goto 770
780 next
790 if W(m)>0 goto 980
800 a=0: x=0
810 get E$: if E$>"" then N(0)=asc(E$): goto 810
820 d=E(N(a)): e=c+I(d)
830 if C(e)>0 goto 860
840 if a=0 then a=1: goto 820
850 e=c+B(A(b)): if e=c then x=7
860 if P(e)=126 then gosub 1000
890 for v=0 to 1
900 w=c-J(d,v): y=x
910 if P(w) then poke 1024+w,P(w): y=1
920 poke 55296+w,y
930 w=e-K(d,v)
940 poke 55296+w,7
950 if P(w) then poke 1024+w,224: if C(w)<0 then P(w)=0
960 next
970 N(1)=N(a): b=C(e): c=e
980 next
990 goto 550
1000 for v=0 to 3
1010 w=e-J(v,0): P(w)=0
1020 poke 1024+w,224
1030 T(v)=11
1040 next
1050 return
2000 data 5,-5,5,-5,5,-5
2010 data 1,2,-1,3,40,4,-40,5
2020 data -1,-1,-1,1,1,-1,1,1
2030 data 0,417,1,423,1,497,0,503
2040 data 1,40,41,0,41,0,40,1
2100 data "000000000","222222333"
2110 data "022022022","033033033"
2120 data "222222333","000000000"
2130 data "221221221","331331331"
2140 data "222000000","222111111"
2150 data "000000000","001001001"
2160 data "000000333","111111333"
2170 data "001001001","000000000"
2180 data "222000333","222111333"
2190 data "021021021","031031031"
2200 data ".0.0.0.0.0.0.0.0.0//"
2210 data "01:::::7:::::::::2//"
2220 data "0:////0:////////0://"
2230 data "-:.0.0.:.0.0.0.0.:.0"
2240 data "05:::::8:::::::::9::"
2250 data "0://////////////0://"
2260 data ".:.0.0.0//0000000:00"
2270 data "03:::::2//01:::::8:2"
2280 data "//////.://0://////0:"
2290 data "//////0://0://00000:"
2300 data "000000.:000://01:::4"
2310 data "0;:::::9:::6//0:0000"
2320 data "//////.://0://03::::"
2330 data "//////0://0:////////"
2340 data ".0.0.0.://0:000000//"
2350 data "01:::::6//03:::::2//"
2360 data "0:////0:////////0://"
2370 data ".:.0.0.:.0.0.0.0.:00"
2380 data "03:::::9:::7:::::8::"
2390 data "//////0://0:////////"
2400 data "-0.0.0.://.:.0.0.0//"
2410 data "01:::::4//03:::::2//"
2430 data "0://////////////0://"
2440 data ".:.0.0.0.0.0.0.0.:.0"
2450 data "03:::::::::::::::8::"