program  black_box0 ; { servidor basado en conductos }
                     { disennado para funcionamiento continuo }
{ 13-08-06 se incorporaron las tablas }
const  bbb : array[1..4614] of byte =   
 (0,0,0,0,0,0,0,1,1,1,1,3,1,0,1,1,1,2,2,1,0,1,2,1,1,1,1,
0,1,1,1,2,1,1,0,3,1,3,1,1,1,0,1,1,3,1,1,1,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,
0,1,3,1,1,1,1,1,1,1,1,1,1,1,0,1,1,2,1,1,1,1,1,1,1,1,1,1,
0,1,1,1,3,1,1,1,1,1,1,1,1,1,0,1,1,1,1,2,1,1,1,1,1,1,1,1,
0,1,1,1,1,1,2,1,1,1,1,1,1,1,0,1,1,1,1,1,1,2,1,1,1,1,1,1,
0,1,1,1,1,1,1,1,2,1,1,1,1,1,0,1,1,1,1,1,1,1,1,3,1,1,1,1,
0,1,1,1,1,1,1,1,1,1,3,1,1,1,0,1,1,1,1,1,1,1,1,1,1,2,1,1,
0,1,1,1,1,1,1,1,1,1,1,1,2,1,0,1,1,1,1,1,1,1,1,1,1,1,1,3,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,
3,1,3,1,0,1,1,1,1,1,0,1,3,1,2,1,0,1,1,1,1,1,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,3,3,2,2,3,3,0,3,1,1,1,1,2,0,3,1,1,1,1,2,
0,2,1,1,1,1,3,0,2,1,1,1,1,3,0,3,2,2,2,3,2,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,2,3,2,3,2,2,3,3,3,3,3,2,3,2,2,2,3,2,2,3,3,2,3,3,
2,2,2,3,2,2,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,2,0,3,1,1,1,1,1,1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,3,3,2,2,2,3,3,3,0,2,2,2,3,3,3,2,2,2,2,
3,2,0,2,3,3,3,3,3,2,2,2,2,2,3,0,3,3,2,3,2,2,2,2,3,3,2,2,
0,2,3,2,3,3,3,2,2,2,3,3,2,0,3,3,2,3,3,3,2,2,3,2,3,2,0,2,
3,2,3,2,3,2,3,3,2,2,2,0,2,2,2,2,2,3,2,2,3,3,2,2,0,3,2,2,
3,3,3,2,3,2,2,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ) ;
   size : array[1..15] of integer = ( 6, 13, 5, 6, 30,
                                       5, 6,30, 8, 21,
                                      30, 9,10, 11, 12 ) ;
   ori : array[1..15] of integer = (   0,   56,  266,  308,  364,
                                    1356, 1398, 1454, 2446, 2536,
                                    3042, 4034, 4144, 4276, 4432 ) ;

var
   pin, pout : file of char ;
{   c : char ;}
   si, lBB, Sb, S1, hits, i{, Len }: LongInt;
   {ar, sin, sout : Text;}
   accion : char ;
   {a : string[4] ;}
   av : array[0..3] of LongInt ;
   BB, bb0 : array[1..1000] of  byte ;

Procedure  WriteChar( c : char ) ;
begin
   {writeln( 'black_box0: WriteChar: ', c ) ;}
   write( pout, c ) ;
   end ;

Function  ReadChar( var c : char ) : boolean ;
begin
   read( pin, c ) ;
   ReadChar :=  c = '{' ; 
   if  c = '{'  then  begin
      WriteChar( '|' ) ;
      {WriteChar( '\' ) ;}
      end ;
   {writeln( 'black_box0: ReadChar: ', c ) ;}
   end ;

begin
   { Instructions executed one time }
   assign( pin, '/var/tmp/to_box' ) ;
   reset( pin ) ;
   assign( pout, '/var/tmp/from_box' );
   rewrite( pout ) ;

   repeat {for ever}
      { ignoring non start characters } 
      repeat 
         read( pin, accion ) ;
         { writeln( 'black_box0:', accion ) ;}
         until  accion = '{' ;
      write( pout, '}' ) ;

      if  ReadChar( accion ) then  continue;
      {writeln( 'Pide conectarse con caja: ', accion ) ; }
      Sb := size[ord(accion)-32] ;
      S1 := Sb + 1 ;
      lBB := S1 * S1 ;
      for  i := 1  to lBB+S1 do  bb0[i] := bbb[i+ori[ord(accion)-32]];
      BB := bb0 ;
      av[0] := S1 ;   av[1] := -1 ;   av[2] := -S1 ;   av[3] := 1 ;
      {writeln( 'black_box0:  envìo: ', chr(Sb+32), Sb ) ;}
      WriteChar( char(Sb+32) ) ;
      {write( pout, 'abcdefg' ) ;}
      while  not ReadChar( accion )  do  
         case  accion  of
              'F': begin
                     { writeln( 'Finish' ); }
              	     {Close(pin);
          	     Close(pout);}
         	     {Say('Connection closed.');}
            	     break ;
		     end ;
              'R': begin
            	     {writeln( 'Reset' ) ;  }
	    	     BB := bb0 ;
		     end ;
              'I': begin
            	     {writeln( 'Toggle' ) ; }
	    	     for  i := Sb to lBB do
			if  BB[i] > 1  then  BB[i] := 5 - BB[i] ;
		     end ;
              'T': begin
                     if  ReadChar( accion )   then  break ;
                     si := ord( accion ) - 65 ;
                     if  ReadChar( accion )   then  break ;
            	     {write( 'Throw ', si, ord( accion )-32  ) ; }
                     case  si  of
			0 :  i := ord( accion ) - 32 ;
	    		1 :  i := ( ord( accion ) - 31 ) * S1 ;
	    		2 :  i := lBB + ord( accion ) - 32 ;
	    		3 :  i := ( ord( accion ) - 32 ) * S1 ;
			end ;
	    	     hits := 0 ;
		     repeat
			Inc( i, av[si] ) ;
			if  BB[i] > 1  then  begin
			   Inc( hits ) ;
        		   si := si xor 1 ;
			   if  BB[i] = 3  then   si := si xor 2 ;
			   BB[i] := BB[i] xor 1 ;
			   end ;
	    		until  BB[i] = 0 ;
	    	     if  si = 0 then  i := i mod S1 ;
	    	     if  si = 1 then  i := i div S1 ;
	    	     if  si = 3 then  i := i div S1 - 1 ;
	    	     {writeln( si, i ) ;}
	    	     WriteChar( chr( si xor 2 + 65 ) ) ;
	    	     WriteChar( chr( i + 32 ) ) ;
	    	     {a := '' ;}
	    	     for  i := 1 to 4  do  begin
			write( pout, chr( hits and 63 + 32 ) ) ;
		        hits := hits shr 6 ;	
			end ;
		     end ;
              else  break ;
		    {writeln( 'No entiendo ', ord(accion) ) ;}
	      end ;
      { all the breaks como to this point }
      until  false ;
end.






