program mafandegancaodabaoji;
var
n,i,j,qidong,work,t,w,d:longint;
xt,yt:real;
father,team:array[0..1050]of longint;
zhuansu,x,y,r,f:array[1..1050] of real;
begin
assign (input,'baler.in');
reset (input);
assign (output,'baler.out');
rewrite (output);
readln (n,xt,yt);
for i:=1 to n do
begin
readln (x[i],y[i],r[i]);
if (x[i]=0)and(y[i]=0) then
qidong:=i;
if (x[i]=xt)and(y[i]=yt) then
work:=i
end;
team[1]:=qidong;
f[1]:=10000;
zhuansu[1]:=10000;
father[1]:=0;
t:=1;
w:=1;
if (xt=0)and(yt=0) then
writeln (10000);
repeat
d:=team[t];
for i:=1 to n do
if (i<>team[father[t]])
and (sqr(x[d]-x[i])+sqr(y[d]-y[i])=sqr(r[d]+r[i])) then
begin
w:=w+1;
team[w]:=i;
zhuansu[w]:=zhuansu[t]*r[d]/r[i];
father[w]:=t;
f[w]:=f[t]+zhuansu[w];
if i=work then
begin
writeln (trunc(f[w]));
close (input);
close (output);
halt
end
end;
t:=t+1
until false;
close (input);
close (output)
end.