program apple;
var
p:array[1..100,1..100] of extended;
a:array[1..100,1..2] of integer;
i,j,n,v,x,y,f,k,po:integer;
d,max,temp:extended;
c:array[1..100] of boolean;
begin
fillchar(c,sizeof(c),false);
////////////////////////////读取
readln(n,v);
for i:=1 to n do begin
readln(x,y,f);
a[i,1]:=x;
a[i,2]:=y;
if (i<>1) then begin
temp:=sqrt(sqr(x-a[f,1])+sqr(y-a[f,2]))/v;
if (temp<p[f,i]) or(p[f,i]=0)then p[f,i]:=temp;
end;
for j:=1 to i do begin
d:=sqrt(2*abs(y-a[j,2])/10);
if (x=a[j,1]) then begin
if (y>a[j,2]) then if (p[i,j]=0) or(d<p[i,j]) then p[i,j]:=d;
if (y<a[j,2]) then if (p[j,i]=0) or(d<p[j,i]) then p[j,i]:=d;
end;
end;
end;
//最短路
c[1]:=true;
for i:=1 to n-1 do begin
max:=maxint;
for j:=1 to n do begin
if (p[1,j]<>0)and(p[1,j]<max) and (c[j]=false) then begin
max:=p[1,j];
po:=j;
end;
end;
c[po]:=true;
for j:=1 to n do begin
if (p[po,j]<>0) and (not c[j]) then begin
if (p[po,j]+max<p[1,j]) or (p[1,j]=0) then p[1,j]:=p[po,j]+max;
end;
end;
end;
writeln(p[1,n]:0:2);
end.