program pil_13_10(input,output);
type
	field = record
		vertical : (a,b,c,d,e,f,g,h);
		horizontal : 1..8;
  end;

var
	n1, n2 : field;
  x1, x2 : char;

function QueenWay(n1, n2 : field) : boolean;
var
  x1, x2 : integer;
begin
	x1 := ord(n1.vertical)+1;
  x2 := ord(n2.vertical)+1;
	QueenWay :=    ((x1/n1.horizontal) = (x2/n2.horizontal))
              or (x1 = x2)
              or (n1.horizontal = x2/n2.horizontal);

end;

begin
	Write('Input first postion : ');
  ReadLn(x1, n1.horizontal);
	Write('Input second postion : ');
  Read(x2, n2.horizontal);

  case x1 of
  	'a' : n1.vertical := a;
    'b' : n1.vertical := b;
    'c' : n1.vertical := c;
    'd' : n1.vertical := d;
    'e' : n1.vertical := e;
    'f' : n1.vertical := f;
    'g' : n1.vertical := g;
    'h' : n1.vertical := h;
  end;
  case x2 of
  	'a' : n2.vertical := a;
    'b' : n2.vertical := b;
    'c' : n2.vertical := c;
    'd' : n2.vertical := d;
    'e' : n2.vertical := e;
    'f' : n2.vertical := f;
    'g' : n2.vertical := g;
    'h' : n2.vertical := h;
  end;
	WriteLn(QueenWay(n1,n2));
end.
