IN H
IN G

MOV C 0

IN D ; TYPE
IN A
IN B
MOV E 1
CMP D E
JZ 28
;.................UPD
IN E
MOV F A
CMP F B
JZ 24
LOAD F A
ADD A E
STORE F A
ADD F 1
MOV RES 0
JZ 15
MOV RES 0
JZ 40
;.................QRY
MOV D 0
MOV F A
CMP F B
JZ 37
LOAD F A
ADD D A
ADD F 1
MOV RES 0
JZ 30
OUT D

ADD C 1
CMP G C
JZ 6

RETURN
