forked from QPong/QPong-PICO-8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqpong.p8
929 lines (812 loc) · 29.7 KB
/
qpong.p8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
pico-8 cartridge // http://www.pico-8.com
version 29
__lua__
-- math.p8
-- This code is part of Qiskit.
--
-- Copyright IBM 2020
-- Custom math table for compatibility with the Pico8
math = {}
math.pi = 3.14159
math.max = max
math.sqrt = sqrt
math.floor = flr
function math.random()
return rnd(1)
end
function math.cos(theta)
return cos(theta/(2*math.pi))
end
function math.sin(theta)
return -sin(theta/(2*math.pi))
end
function math.randomseed(time)
end
os = {}
function os.time()
end
-- MicroQiskit.lua
-- This code is part of Qiskit.
--
-- Copyright IBM 2020
math.randomseed(os.time())
function QuantumCircuit ()
local qc = {}
local function set_registers (n,m)
qc.num_qubits = n
qc.num_clbits = m or 0
end
qc.set_registers = set_registers
qc.data = {}
function qc.initialize (ket)
ket_copy = {}
for j, amp in pairs(ket) do
if type(amp)=="number" then
ket_copy[j] = {amp, 0}
else
ket_copy[j] = {amp[0], amp[1]}
end
end
qc.data = {{'init',ket_copy}}
end
function qc.add_circuit (qc2)
qc.num_qubits = math.max(qc.num_qubits,qc2.num_qubits)
qc.num_clbits = math.max(qc.num_clbits,qc2.num_clbits)
for g, gate in pairs(qc2.data) do
qc.data[#qc.data+1] = ( gate )
end
end
function qc.x (q)
qc.data[#qc.data+1] = ( {'x',q} )
end
function qc.rx (theta,q)
qc.data[#qc.data+1] = ( {'rx',theta,q} )
end
function qc.h (q)
qc.data[#qc.data+1] = ( {'h',q} )
end
function qc.cx (s,t)
qc.data[#qc.data+1] = ( {'cx',s,t} )
end
function qc.measure (q,b)
qc.data[#qc.data+1] = ( {'m',q,b} )
end
function qc.rz (theta,q)
qc.h(q)
qc.rx(theta,q)
qc.h(q)
end
function qc.ry (theta,q)
qc.rx(math.pi/2,q)
qc.rz(theta,q)
qc.rx(-math.pi/2,q)
end
function qc.z (q)
qc.rz(math.pi,q)
end
function qc.y (q)
qc.z(q)
qc.x(q)
end
return qc
end
function simulate (qc, get, shots)
if not shots then
shots = 1024
end
function as_bits (num,bits)
-- returns num converted to a bitstring of length bits
-- adapted from https://stackoverflow.com/a/9080080/1225661
local bitstring = {}
for index = bits, 1, -1 do
b = num - math.floor(num/2)*2
num = math.floor((num - b) / 2)
bitstring[index] = b
end
return bitstring
end
function get_out (j)
raw_out = as_bits(j-1,qc.num_qubits)
out = ""
for b=0,qc.num_clbits-1 do
if outputnum_clbitsap[b] then
out = raw_out[qc.num_qubits-outputnum_clbitsap[b]]..out
end
end
return out
end
ket = {}
for j=1,2^qc.num_qubits do
ket[j] = {0,0}
end
ket[1] = {1,0}
outputnum_clbitsap = {}
for g, gate in pairs(qc.data) do
if gate[1]=='init' then
for j, amp in pairs(gate[2]) do
ket[j] = {amp[1], amp[2]}
end
elseif gate[1]=='m' then
outputnum_clbitsap[gate[3]] = gate[2]
elseif gate[1]=="x" or gate[1]=="rx" or gate[1]=="h" then
j = gate[#gate]
for i0=0,2^j-1 do
for i1=0,2^(qc.num_qubits-j-1)-1 do
b1=i0+2^(j+1)*i1 + 1
b2=b1+2^j
e = {{ket[b1][1],ket[b1][2]},{ket[b2][1],ket[b2][2]}}
if gate[1]=="x" then
ket[b1] = e[2]
ket[b2] = e[1]
elseif gate[1]=="rx" then
theta = gate[2]
ket[b1][1] = e[1][1]*math.cos(theta/2)+e[2][2]*math.sin(theta/2)
ket[b1][2] = e[1][2]*math.cos(theta/2)-e[2][1]*math.sin(theta/2)
ket[b2][1] = e[2][1]*math.cos(theta/2)+e[1][2]*math.sin(theta/2)
ket[b2][2] = e[2][2]*math.cos(theta/2)-e[1][1]*math.sin(theta/2)
elseif gate[1]=="h" then
for k=1,2 do
ket[b1][k] = (e[1][k] + e[2][k])/math.sqrt(2)
ket[b2][k] = (e[1][k] - e[2][k])/math.sqrt(2)
end
end
end
end
elseif gate[1]=="cx" then
s = gate[2]
t = gate[3]
if s>t then
h = s
l = t
else
h = t
l = s
end
for i0=0,2^l-1 do
for i1=0,2^(h-l-1)-1 do
for i2=0,2^(qc.num_qubits-h-1)-1 do
b1 = i0 + 2^(l+1)*i1 + 2^(h+1)*i2 + 2^s + 1
b2 = b1 + 2^t
e = {{ket[b1][1],ket[b1][2]},{ket[b2][1],ket[b2][2]}}
ket[b1] = e[2]
ket[b2] = e[1]
end
end
end
end
end
if get=="statevector" then
return ket
else
probs = {}
for j,amp in pairs(ket) do
probs[j] = amp[1]^2 + amp[2]^2
end
if get=="expected_counts" then
c = {}
for j,p in pairs(probs) do
out = get_out(j)
if c[out] then
c[out] = c[out] + probs[j]*shots
else
if out then -- in case of pico8 weirdness
c[out] = probs[j]*shots
end
end
end
return c
else
m = {}
for s=1,shots do
cumu = 0
un = true
r = math.random()
for j,p in pairs(probs) do
cumu = cumu + p
if r<cumu and un then
m[s] = get_out(j)
un = false
end
end
end
if get=="memory" then
return m
elseif get=="counts" then
c = {}
for s=1,shots do
if c[m[s]] then
c[m[s]] = c[m[s]] + 1
else
if m[s] then -- in case of pico8 weirdness
c[m[s]] = 1
else
if c["error"] then
c["error"] = c["error"]+1
else
c["error"] = 1
end
end
end
end
return c
end
end
end
end
-- QPong
started=false
ended=false
scored = ""
blink_timer = 0
function newgame()
started = true
ended = false
player_points = 0
com_points = 0
--variables
counter=0
player={
x = 117,
y = 63,
color = 12,
width = 2,
height = 10,
speed = 1
}
com={
x = 8,
y = 63,
color = 8,
width = 2,
height = 10,
speed = 0
}
gate_type={
x = 0,
y = 1,
z = 2,
h = 3
}
gate_seq={
I=1,
X=2,
Y=3,
Z=4,
H=5
}
gates={
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1}
}
-- Relative frequency of the measurement results
-- Obtained from simulator
probs = {1, 0, 0, 0, 0, 0, 0, 0}
--probs={0.5, 0.5, 0, 0, 0, 0, 0, 0}
--meas_probs={1, 0, 0, 0, 0, 0, 0, 0}
-- How many updates left does the paddle stays measured
measured_timer = 0
cursor = {
row=0,
column=0,
x=0,
y=0,
sprite=16
}
--sound
if scored=="player" then
sfx(3)
elseif scored=="com" then
sfx(4)
else
sfx(5)
end
--court
court={
left=0,
right=127,
top=0,
bottom=82,
edge=107, --when ball collide this line, measure the circuit
color=5
}
--court center line
dash_line={
x=63,
y=0,
length=1.5,
color=5
}
--circuit composer
composer={
left=0,
right=127,
top=82,
bottom=127,
color=7
}
qubit_line={
x=10,
y=90,
length=108,
separation=15,
color=5
}
newRound()
end
function newRound()
if scored == "player" then
ball={
x = 30,
y = 30 + rnd(5),
color = 7,
width = 2,
dx = 0.6,
dy = rnd() - 0.5,
speed = 1,
speedup = 0.05
}
else
ball={
x = 98,
y = 30 + rnd(5),
color = 7,
width = 2,
dx = -0.6,
dy = rnd() - 0.5,
speed = 1,
speedup = 0.05
}
end
end
function _draw()
cls()
if not started then
if blink_timer < 40 then
print("press z", 50, 80, 10)
end
for i = 0, 10 do
for j = 0, 3 do
spr(64 + i + 16 * j,
20 + 8 * i,
30 + 8 * j)
end
end
for i = 0,2 do
--print IBM logo
spr(i+140,i*8+64,104)
spr(i+156,i*8+64,112)
--print NTU logo
spr(i+172,i*8+104,104)
spr(i+188,i*8+104,112)
end
spr(160,92,112)
elseif ended then
if scored == "player" then
--player win
--TODO 192 208
print("you demostrated", 20 , 20 , 8)
for i = 1,4 do
spr(i+200,20+8*i,30)
end
for i = 1,5 do
spr(i+216,63+8*i,30)
end
spr(236,95,38)
spr(237,103,38)
--cat
sspr(25,97,16,16,0,96,32,32)
--[[ spr(195,0,112)
spr(196,8,112)
spr(211,0,120)
spr(212,8,120) ]]
--qiskit
spr(199,100,10)
spr(200,108,10)
spr(215,100,18)
spr(216,108,18)
print("for the first time ",53,46,8)
print("in human history!",53,54,8)
--com win
--TODO
else
print("classical computers",20,30,8)
print("still rule the world!",40,50,8)
--cat
sspr(1,97,16,16,0,96,32,32)
--[[ spr(192,0,112)
spr(193,8,112)
spr(208,0,120)
spr(209,8,120) ]]
--computer
spr(197,100,10)
spr(198,108,10)
spr(213,100,18)
spr(214,108,18)
end
--restart
if blink_timer < 40 then
print("press z to restart", 30, 80, 10)
end
else --game is running
--court
rect(court.left,court.top,court.right,court.bottom,court.color)
--dashed center line
repeat
line(dash_line.x,dash_line.y,dash_line.x,dash_line.y+dash_line.length,dash_line.color)
dash_line.y += dash_line.length*2
until dash_line.y > court.bottom-1
dash_line.y = 0 --reset
--circuit composer
rectfill(composer.left,composer.top,composer.right,composer.bottom,composer.color)
--qubit lines
repeat
line(qubit_line.x,qubit_line.y,qubit_line.x+qubit_line.length,qubit_line.y,qubit_line.color)
qubit_line.y += qubit_line.separation
until qubit_line.y > composer.bottom-1
qubit_line.y = 90 --reset
for slot = 1, 8 do
for wire = 1, 3 do
gnum = gates[wire][slot] - 2
if gnum != -1 then
spr(gnum,
qubit_line.x + (slot - 1) * qubit_line.separation - 4,
qubit_line.y + (wire - 1) * qubit_line.separation - 4)
end
end
end
--cursor
cursor.x=qubit_line.x+cursor.column*qubit_line.separation-4
cursor.y=qubit_line.y+cursor.row*qubit_line.separation-4
spr(cursor.sprite,cursor.x,cursor.y)
for x=0,7 do
spr(6, 94, 10 * x + 2)
a=x%2
b=flr(x/2)%2
c=flr(x/4)%2
spr(c+4, 97, 10 * x + 2)
spr(b+4, 102, 10 * x + 2)
spr(a+4, 107, 10 * x + 2)
spr(7, 111, 10 * x + 2)
end
--player
for y=0,7 do
local color
local prob = probs[y + 1] --supposed to be inverse power of 2 but I'm allowing .01 error
if prob > .99 then
color = 7
elseif prob > .49 then
color = 6
elseif prob > .24 then
color = 13
elseif prob > .11 then
color = 5
else
color = 0
end
rectfill(
player.x,
10 * y + 1,
player.x + player.width,
10 * y + player.height,
color
)
end
--ball
rectfill(
ball.x,
ball.y,
ball.x + ball.width,
ball.y + ball.width,
ball.color
)
--computer
rectfill(
com.x,
com.y,
com.x + com.width,
com.y + com.height,
com.color
)
--scores
print(player_points,66,2,player.color)
print(com_points,58,2,com.color)
end
end
function simCir()
qc = QuantumCircuit()
qc.set_registers(3,3)
for slots = 1,8 do
for wires = 1,3 do
if (gates[wires][slots] == 2) then
qc.x(wires-1)
elseif (gates[wires][slots] == 3) then
qc.y(wires-1)
elseif (gates[wires][slots] == 4) then
qc.z(wires-1)
elseif (gates[wires][slots] == 5) then
qc.h(wires-1)
end
end
end
qc.measure(0,0)
qc.measure(1,1)
qc.measure(2,2)
result = simulate(qc,'expected_counts',1)
for key, value in pairs(result) do
print(key,value)
idx = tonum('0b'..key) + 1
probs[idx]=value
end
end
function meas_prob()
idx = -1
math.randomseed(os.time())
r=math.random()
--r =0.2
--print(r)
num =0
for i = 1,8 do
if (r > probs[i]) then
num=r-probs[i]
r=num
elseif (r<=probs[i]) then
idx = i
break
end
end
for i = 1,8 do
if i==idx then
probs[i]=1
else
probs[i]=0
end
end
return idx
end
function _update60()
blink_timer = (blink_timer + 1) % 60
--player controls
if (not started) or ended then
if btnp(4) then
newgame()
end
else
if btnp(2)
and cursor.row > 0 then
cursor.row -= 1
end
if btnp(3)
and cursor.row < 2 then
cursor.row += 1
end
if btnp(0)
and cursor.column > 0 then
cursor.column -= 1
end
if btnp(1)
and cursor.column < 7 then
cursor.column += 1
end
if btnp(5) then
cur_gate = gates[cursor.row+1][cursor.column+1]
if cur_gate==2 then
gates[cursor.row+1][cursor.column+1]=1
else
gates[cursor.row+1][cursor.column+1]=2
end
simCir()
end
if btnp(4) then
cur_gate = gates[cursor.row+1][cursor.column+1]
if cur_gate==5 then
gates[cursor.row+1][cursor.column+1]=1
else
gates[cursor.row+1][cursor.column+1]=5
end
simCir()
end
--computer controls
com.y += com.speed
com.y = max(com.y, 1)
com.y = min(com.y, 70)
local mid_com = com.y + (com.height/2)
local r = rnd()
if ball.y - mid_com > 0 then
if r < .5 then
com.speed = min(com.speed + .05, .6)
elseif r > .75 then
com.speed = max(com.speed - .05, -.6)
end
else
if r < .5 then
com.speed = max(com.speed - .05, -.6)
elseif r > .75 then
com.speed = min(com.speed + .05, .6)
end
end
--score
if ball.x > court.right then
com_points += 1
scored = "com"
if com_points < 7 then
newRound()
else
ended = true
end
end
if ball.x < court.left then
player_points += 1
scored = "player"
if player_points < 7 then
newRound()
else
ended = true
end
end
--collide with court
if ball.y + ball.width >= court.bottom - 1
or ball.y <= court.top+1 then
ball.dy = -ball.dy
sfx(2)
end
--collide with com
if ball.dx < 0
and ball.x <= com.x+com.width
and ball.x >com.x
and ((ball.y+ball.width<=com.y+com.height and ball.y+ball.width>=com.y)or(ball.y<=com.y+com.height and ball.y>=com.y))
then
ball.dy -= ball.speedup*2
--flip ball DX and add speed
ball.dx = -(ball.dx - ball.speedup)
sfx(1)
end
--TODO: when ball collide on edge--> measure
--UNTEST
if ball.x > court.edge and counter==0 then
counter=30
meas_prob()
for i=1,8 do
if probs[i] == 1 then
beg = 10 * (i - 1)
player.y = beg
end
end
elseif ball.x < court.edge and counter > 0 then
counter-=1
if counter==0 then
simCir()
end
end
------------------------
--collide with player
if ball.dx > 0
and ball.x <= player.x+player.width
and ball.x> player.x
and ((ball.y+ball.width<=player.y+player.height and ball.y+ball.width>=player.y)or(ball.y<=player.y+player.height and ball.y>=player.y))
then
ball.dy -= ball.speedup*2
--flip ball DX and add speed
ball.dx = -(ball.dx - ball.speedup)
sfx(1)
end
--ball movement
ball.x += ball.dx
ball.y += ball.dy
end
end
__gfx__
66666661666666616666666166666661000000000000000010000000010000000000000000000000000000000000000000000000000000000000000000000000
61666161616661616111116161666161011000000010000010000000001000000000000000000000000000000000000000000000000000000000000000000000
66161661661616616666166161666161100100000110000010000000001000000000000000000000000000000000000000000000000000000000000000000000
66616661666166616661666161111161100100000010000010000000000100000000000000000000000000000000000000000000000000000000000000000000
66161661666166616616666161666161100100000010000010000000000100000000000000000000000000000000000000000000000000000000000000000000
61666161666166616111116161666161011000000010000010000000001000000000000000000000000000000000000000000000000000000000000000000000
66666661666666616666666166666661000000000000000010000000001000000000000000000000000000000000000000000000000000000000000000000000
11111111111111111111111111111111000000000000000010000000010000000000000000000000000000000000000000000000000000000000000000000000
c0c0c0c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0c0c0c0c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
11000000000000000000000000001110000000001100000000000000000000000000001100000000000000000000000000000000000000000000000000000000
11000000000000000000000000000111000000001100000000000000000000000000000110000000000000000000000000000000000000000000000000000000
11000000000099999999000000000011000000001100000000000000000000000000000110000000000000000000000000000000000000000000000000000000
11000000000999999999900000000001100000001100099999999999000000000000000011000000000000000000000000000000000000000000000000000000
11000000099900000009990000000001100000001100099999999999990000000000000011100000000000000000000000000000000000000000000000000000
11000000999900000000999000000000110000001100099900000009999000000000000001100000000000000000000000000000000000000000000000000000
11000009990000000000099900000000110000001100099900000000099000000000000000110000000000000000000000000000000000000000000000000000
11000009900000000000009990000000111000001100099900000000009900000000000000110000000000000000000000000000000000000000000000000000
11000099900000000000000990000000011000001100099900000000009900000000000000011000000000000000000000000000000000000000000000000000
11000099900000000000000999000000011000001100099900000000009900000000000000011100000000000000000000000000000000000000000000000000
11000099000000000000000099000000001100001100099900000000009900000000000000001100000000000000000000000000000000000000000000000000
11000999000000000000000099000000001100001100099900000000009900000000000000001110000000000000000000000000000000000000000000000000
11000990000000000000000099000000000100001100099900000000099000000000000000000110000000000000000000000000000000000000000000000000
11000990000000000000000099000000000110001100099900000000999000000000000000000011000000000000000000000000000000000000000000000000
11000990000000000000000009900000000011001100099999999999990000000000000000000011000000000000000000000000000000000000000000000000
11000990000000000000000009900000000011001100099999999999000000000000000000000001100000000000000000000000000000000000000000000000
11000990000000000000000009900000000011001100099000000000000000000000000000000001100000000000000000000000000000000000000000000000
11000999000000000009900009900000000110001100099000000000000000000000000000000011000000000000000000000000000000000000000000000000
11000999000000000009900099000000000100001100099000000000000000000000000000000011000000000000000000000000000000000000000000000000
11000099000000000009990099000000001100001100099000000000000000000000000000000110000000000000000000000000000000000000000000000000
11000099000000000000999099000000001100001100099000099900090990000990000000000110000000000000000000000000000000000000000000000000
11000009900000000000099090000000011000001100099000990990099009009009000000000100000000000000000000000000000000000000000000000000
11000009900000000000009990000000111000001100099000900090090009009009000000001100000000000000000000000000000000000000000000000000
11000009990000000000099900000000110000001100099000990990090009000999000000001100000000000000000000000000000000000000000000000000
11000000999000000009999990000001100000001100099000099900090009000009900000001000000000000000000000000000000000000000000000000000
11000000009999000999990999000001100000001100099000000000000000000099000000011000000000000000000000000000000000000000000000000000
11000000000999999999000099900011000000001100000000000000000000000909000000011000000000000000000000000000000000000000000000000000
11000000000000999000000009900011000000001100000000000000000000009009000000110000000000000000000000000000000000000000000000000000
11000000000000000000000000000110000000001100000000000000000000009090000001100000000000000000000000000000000000000000000000000000
11000000000000000000000000000110000000001100000000000000000000000900000001100000000000000000000000000000000000000000000000000000
11000000000000000000000000001100000000001100000000000000000000000000000011000000000000000000000000000000000000000000000000000000
11000000000000000000000000001100000000001100000000000000000000000000000011000000000000000000000000000000000000000000000000000000
cccccccc0cccccccccccc000ccccc000000000ccccc00000111000000000111088888888888880333000000333000000cccc0cccccc00cc0000000cc00000000
00000000000000000000000000000000000000000000000011110000000011108888888888888033300000033300000000000000000000000000000000000000
cccccccc0ccccccccccccc00cccccc0000000cccccc00000111110000000111088888888888880333000000333000000cccc0ccc0ccc0ccc00000ccc00000000
00000000000000000000000000000000000000000000000011111100000011100000088800000033300000033300000000000000000000000000000000000000
00cccc00000ccc00000ccc0000ccccc00000ccccc00000001111111000001110000008880000003330000003330000000cc000c00ccc00ccc000ccc000000000
00000000000000000000000000000000000000000000000011111111000011100000088800000033300000033300000000000000000000000000000000000000
00cccc00000ccccccccc000000cccccc000cccccc00000001110111110001110000008880000003330000003330000000cc000ccccc000cccc0cccc000000000
00000000000000000000000000000000000000000000000011100111110011100000088800000033300000033300000000000000000000000000000000000000
00cccc00000ccccccccc000000ccc0ccc0ccc0ccc00000001110001111101110000008880000003330000003330000000cc000c00cc000cc0c0c0cc000000000
00000000000000000000000000000000000000000000000011100001111111100000088800000033300000033300000000000000000000000000000000000000
00cccc00000ccc00000ccc0000ccc00ccccc00ccc00000001110000011111110000008880000003330000003330000000cc000c00ccc00cc0ccc0cc000000000
00000000000000000000000000000000000000000000000011100000011111100000088800000033300000033300000000000000000000000000000000000000
cccccccc0ccccccccccccc00ccccc000ccc000ccccc00000111000000011111000000888000000333300003333000000cccc0ccccccc0ccc00c00ccc00000000
00000000000000000000000000000000000000000000000011100000000111100000088800000033333333333300000000000000000000000000000000000000
cccccccc0cccccccccccc000ccccc0000c0000ccccc00000111000000000111000000888000000033333333330000000cccc0cccccc00ccc00000ccc00000000
00000000000000000000000000000000000000000000000011100000000011100000088800000003333333333000000000000000000000000000000000000000
0eeeeee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd00000dd88888888330003300000000
e000000e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd00000dd88888888330003300000000
e0e00e0e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd00000dd00088000330003300000000
e00ee00e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd00000dd00088000330003300000000
e00ee00e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ddd0000dd00088000330003300000000
e0e00e0e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dddd000dd00088000330003300000000
e000000e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ddddd00dd00088000330003300000000
0eeeeee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dddddd0dd00088000330003300000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ddddddddd00088000330003300000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd0dddddd00088000330003300000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd00ddddd00088000330003300000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd000dddd00088000330003300000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd0000ddd00088000330003300000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd00000dd00088000333033300000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd00000dd00088000333333300000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd00000dd00088000033333000000000
00000000000b00000000000000000000000000000000000000000000000770777707700000000000000000000000000000000000000000000000000000000000
0000000b00000b0b0000000000000000000000000000000000000000007777000077770009999990000000000000000000000000000000000000000000000000
00000000000b000b0000000000000000000007070000000000000000077777777777777009000090000000000000000000000000000000000000000000000000
00000000b0b00b000000000000000077700007770111111111100000770990000000007709000090000000000000000000000000000000000000000000000000
000000000b0b00b00000000000010000777770700177777777100000707997777777770709000090000000000000900000000000000000000000000000000000
00070070000000000000000000001000007777000177777777100000077779777777777009009090909099909990990909099999000000000000000000000000
000777700b00bb0b0000000000000100007007000179777797100000707777977777770709000990909090909090900909090909000000000000000000000000
00077770000000000000000000000100070070000179799797100000770000090000007709999999999999999099999999990909000000000000000000000000
00077770333333330000000000900001000000000179999997100000777777779777777700000000000000000000000000000000000000000000000000000000
00077770333333330000000000900010001011000111111111100000770000000900007700990000000000000000000000000000000000000000000000000000
00077770333383330000000000900000010000000111111111100000707777777797770709009000900000000000000000000000000000000000000000000000
000777703338a8330000000000999999000000000dddddddddd00000077777777779977009009000900000000000000000000000000000000000000000000000
770777703388a8830000000000999999000000000d06060606d00000707777777779970709009000900000000000009000000000000000000000000000000000
07077770388888880000000000999999000000000d60606060d0d600070000000000007009999099909090999099909909990999099900000000000000000000
077777708888a8880000000000999999000000000d06060606d06600007777777777770009009090909090909090909009090909090900000000000000000000
00077770333333330000000000999999000000000dddd77dddd06600000777000077700009009099900900999990999999999909999900000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009090000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000999099900000000000000000000