program du_zirgai;
  { 14 u‘davinys }
  type pozicija = record  { pad‚tis žachmat— lentoje }
                    x, y : char;
                  end;
  var b, j,   { baltojo ir juodojo ‘irg— pradin‚s koordinat‚s }
      n     : pozicija; { galimas baltojo ‘irgo ‚jimas }
      i     : integer;
      rasta : boolean;
  procedure ejimas (i : integer; { ‚jimo numeris }
                    b : pozicija; var n : pozicija);
    { nustatomos baltojo ‘irgo ‚jimo koordinat‚s }
  begin
    { apskai‡iuojama koordinat‚ x }
    case i of
      1, 4 : n.x := succ (b.x);
      2, 3 : n.x := succ (succ (b.x));
      5, 8 : n.x := pred (b.x);
      6, 7 : n.x := pred (pred (b.x))
    end;
    { apskai‡iuojama koordinat‚ y }
    case i of
      2, 7 : n.y := succ (b.y);
      1, 8 : n.y := succ (succ (b.y));
      3, 6 : n.y := pred (b.y);
      4, 5 : n.y := pred (pred (b.y))
    end;
  end;
  function gerai (p : pozicija) : boolean;
    { ar ‘irgas nenužoka nuo lentos }
  begin
    gerai := (p.x in ['a'..'h']) and (p.y in ['1'..'8'])
  end;
  function kerta (j, b : pozicija) : boolean;
    { ar juodasis ‘irgas kerta balt…j }
    var dx, dy : integer;
  begin
    dx := abs (ord(j.x) - ord(b.x));
    dy := abs (ord(j.y) - ord(b.y));
    kerta := (dx = 1) and (dy = 2) or (dx = 2) and (dy = 1)
  end;
begin
  write ('­veskite baltojo ‘irgo koordinates: ');
  readln (b.x, b.y);
  write ('­veskite juodojo ‘irgo koordinates: ');
  readln (j.x, j.y);
  rasta := false;
  for i := 1 to 8 do { ižbandomi visi galimi baltojo ‘irgo ‚jimai }
    begin
      ejimas (i, b, n);
      if gerai (n) and not kerta (j, n)
         then begin
                write (n.x, n.y, ' ');
                rasta := true
              end
    end;
  if not rasta
     then writeln ('Baltasis ‘irgas neturi ‚jim—.')
end.