program baudot(input,output); type codearray=packed array[0..31] of char; intarray=array[1..5] of integer; var downflag:boolean; downcode,upcode:codearray; int:intarray; number,J,I,decimal:integer; ch:char; begin for I:= 0 to 30 do begin read(ch); downcode[I]:=ch; end; readln; for I:= 0 to 30 do begin read(ch); upcode[I]:=ch; end; readln; while not eof do begin downflag:=true; J:=0; while (J<>70) do begin for I:=1 to 5 do begin read(ch); if ch<>' ' then begin int[I]:=ord(ch)-ord('O'); J:=J+1; end else J:=70; end; if ch <> ' ' then begin decimal:=int[1]*16+int[2]*8+int[3]*4+int[4]*2+int[5]; if decimal = 31 then downflag:=false; if decimal = 27 then downflag:=true; if (decimal<>31) and (decimal<>27) then if downflag then write(downcode[decimal]) else write(upcode[decimal]) end; end; (*eoln*) readln; writeln; end; (* eof *) end.