unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  math;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  xmin, xmax, ymin, ymax, px, py, pa, da, a1, a2, step, amax, amin: extended;
  cx, cy: longint;
  x, y: array [1..30] of extended;
  col: longint;
  i, j, di, dj, n: longint;
  mind, maxd, dlow, dhigh, maxda, tmp: double;
  an: array [1..30] of double;
  fin: textfile;
begin
  reset(fin, 'shepherd.in');
  read(fin, n, dlow, dhigh);
  xmin := 1000;
  xmax := -1000;
  ymin := 1000;
  ymax := -1000;
  for i := 1 to n do begin
    read(fin, x[i], y[i]);
    xmin := min(xmin, x[i]);
    ymin := min(ymin, y[i]);
    xmax := max(xmax, x[i]);
    ymax := max(ymax, y[i]);
  end;
  closefile(fin);

  xmin := xmin - dhigh - 1;
  ymin := ymin - dhigh - 1;
  xmax := xmax + dhigh + 1;
  ymax := ymax + dhigh + 1;

  step := max((xmax - xmin) / 500, (ymax - ymin) / 500);

  amax := 0;
  amin := pi;
  for di := 0 to 499 do begin
    for dj := 0 to 499 do begin
      px := xmin + di * step;
      py := ymin + dj * step;

      mind := 2000;
      maxd := 0;
      for i := 1 to n do begin
        mind := min(mind, hypot(px - x[i], py - y[i]));
        maxd := max(maxd, hypot(px - x[i], py - y[i]));
      end;

      if (mind < dlow) or (maxd > dhigh) then continue;

      pa := pi;
      for i := 1 to n do begin
        an[i] := arctan2(y[i] - py, x[i] - px);
      end;

      for i := 1 to n do begin
        for j := 1 to n do begin
          if an[i] > an[j] then begin
            tmp := an[i]; an[i] := an[j]; an[j] := tmp;
          end;
        end;
      end;
      maxda := 0;
      for i := 1 to n do begin
        da := an[i mod n + 1] - an[i];
        if (da < 0) then
          da := da + 2 * pi;
        if (da > maxda) then
          maxda := da;
      end;

      maxda := 2 * pi - maxda;

      if maxda > pi then continue;

      maxda := pi - maxda;

      if maxda > amax then
        amax := maxda;
      if maxda < amin then
        amin := maxda;

    end;
  end;

  for di := 0 to 499 do begin
    for dj := 0 to 499 do begin
      px := xmin + di * step;
      py := ymin + dj * step;

      mind := 2000;
      maxd := 0;
      for i := 1 to n do begin
        mind := min(mind, hypot(px - x[i], py - y[i]));
        maxd := max(maxd, hypot(px - x[i], py - y[i]));
      end;

      if (mind < dlow) or (maxd > dhigh) then continue;

      pa := pi;
      for i := 1 to n do begin
        an[i] := arctan2(y[i] - py, x[i] - px);
      end;

      for i := 1 to n do begin
        for j := 1 to n do begin
          if an[i] > an[j] then begin
            tmp := an[i]; an[i] := an[j]; an[j] := tmp;
          end;
        end;
      end;
      maxda := 0;
      for i := 1 to n do begin
        da := an[i mod n + 1] - an[i];
        if (da < 0) then
          da := da + 2 * pi;
        if (da > maxda) then
          maxda := da;
      end;

      maxda := 2 * pi - maxda;

      if maxda > pi then continue;

      maxda := pi - maxda;

      col := round(255 * (maxda - amin) / (amax - amin)) shl 8;
      image1.Canvas.Pixels[di, dj] := col;
    end;
  end;

  reset(fin, 'shepherd.out');
  read(fin, px, py);
  closefile(fin);

  cx := round((px - xmin) / step);
  cy := round((py - ymin) / step);

  image1.Canvas.Pen.Color := clRed;
  image1.Canvas.Ellipse(cx - 2, cy - 2, cx + 2, cy + 2);

  form1.caption := 'Done';
end;

end.
