program baler;
var
a,b:array[1..1050]of longint;
p:array[1..1050]of boolean;
x,y:array[1..1050]of longint;
r:array[1..1050]of int64;
max,v:real;
dd:boolean;
n,zx,zy,i,j,ii,sta,aim:longint;
begin
assign(input,'baler.in');
assign(output,'baler.out');
reset(input);
rewrite(output);
read(n,zx,zy);
for i:=1 to n do
begin
read(x[i],y[i],r[i]);
if (x[i]=0)and(y[i]=0) then sta:=i;
if (x[i]=zx)and(y[i]=zy) then aim:=i;
end;
fillchar(p,sizeof(P),true);
a[1]:=sta;
i:=1; j:=1;
p[sta]:=false;
v:=10000*r[sta];
max:=0;
dd:=false;
repeat
for ii:=1 to n do
if p[ii] then if sqr(r[a[i]]+r[ii])=sqr(x[a[i]]-x[ii])+sqr(y[a[i]]-y[ii])
then begin
j:=j+1;
a[j]:=ii;
p[ii]:=false;
b[j]:=i;
if ii=aim then begin
dd:=true;
break;
end;
end;
i:=i+1;
until dd;
i:=j;
repeat
max:=v/r[a[i]]+max;
i:=b[i];
until a[i]=sta;
max:=max+10000;
writeln(round(max));
close(input);
close(output);
end.