var map:array[0..501,0..501] of double;
flag:array[0..501,0..501] of boolean;
dist:array[0..501] of double;
a:array[0..501] of record x,y:longint;end;
pre:array[0..501] of longint;
i,n,m,num,x,y,j:longint;
max,ans:double;
procedure spfa1;
var h,t,x,i:longint;
vis:array[0..501] of boolean;
q:array[0..501] of longint;
begin
for i:=1 to n do dist[i]:=maxlongint;
fillchar(vis,sizeof(vis),false);
h:=0;t:=1;q[1]:=1;dist[1]:=0;vis[1]:=true;
while h<>t do
begin
h:=h mod n+1;
x:=q[h];
vis[x]:=false;
for i:=1 to n do
if (map[x,i]<>maxlongint) and (dist[x]+map[x,i]<dist[i]) then
begin
dist[i]:=dist[x]+map[x,i];
pre[i]:=x;
if not(vis[i]) then
begin
t:=t mod n+1;
q[t]:=i;
vis[i]:=true;
end;
end;
end;
end;
procedure spfa2;
var h,t,x,i:longint;
vis:array[0..501] of boolean;
q:array[0..501] of longint;
begin
for i:=1 to n do dist[i]:=maxlongint;
fillchar(vis,sizeof(vis),false);
h:=0;t:=1;q[1]:=1;dist[1]:=0;vis[1]:=true;
while h<>t do
begin
h:=h mod n+1;
x:=q[h];
vis[x]:=false;
for i:=1 to n do
if (map[x,i]>0) and (dist[x]+map[x,i]<dist[i]) and (flag[x,i]) then
begin
dist[i]:=dist[x]+map[x,i];
if not(vis[i]) then
begin
t:=t mod n+1;
q[t]:=i;
vis[i]:=true;
end;
end;
end;
end;
begin
assign(input,'pos1.in');assign(output,'output.txt');
reset(input);rewrite(output);
readln(n,m);
for i:=1 to n do readln(a[i].x,a[i].y);
fillchar(pre,sizeof(pre),0);
for i:=1 to n do
for j:=1 to n do
map[i,j]:=maxlongint;
for i:=1 to m do
begin
readln(x,y);
map[x,y]:=sqrt(sqr(a[x].x-a[y].x)+sqr(a[x].y-a[y].y));
map[y,x]:=sqrt(sqr(a[x].x-a[y].x)+sqr(a[x].y-a[y].y));
end;
spfa1;ans:=dist[n];
num:=n;max:=maxlongint;
while num<>0 do
begin
fillchar(flag,sizeof(flag),true);
flag[num,pre[num]]:=false;
flag[pre[num],num]:=false;
spfa2;
if (dist[n]<max) and (dist[n]>=ans) then max:=dist[n];
num:=pre[num];
end;
writeln(max:0:2);
close(input);close(output);
end.
flag:array[0..501,0..501] of boolean;
dist:array[0..501] of double;
a:array[0..501] of record x,y:longint;end;
pre:array[0..501] of longint;
i,n,m,num,x,y,j:longint;
max,ans:double;
procedure spfa1;
var h,t,x,i:longint;
vis:array[0..501] of boolean;
q:array[0..501] of longint;
begin
for i:=1 to n do dist[i]:=maxlongint;
fillchar(vis,sizeof(vis),false);
h:=0;t:=1;q[1]:=1;dist[1]:=0;vis[1]:=true;
while h<>t do
begin
h:=h mod n+1;
x:=q[h];
vis[x]:=false;
for i:=1 to n do
if (map[x,i]<>maxlongint) and (dist[x]+map[x,i]<dist[i]) then
begin
dist[i]:=dist[x]+map[x,i];
pre[i]:=x;
if not(vis[i]) then
begin
t:=t mod n+1;
q[t]:=i;
vis[i]:=true;
end;
end;
end;
end;
procedure spfa2;
var h,t,x,i:longint;
vis:array[0..501] of boolean;
q:array[0..501] of longint;
begin
for i:=1 to n do dist[i]:=maxlongint;
fillchar(vis,sizeof(vis),false);
h:=0;t:=1;q[1]:=1;dist[1]:=0;vis[1]:=true;
while h<>t do
begin
h:=h mod n+1;
x:=q[h];
vis[x]:=false;
for i:=1 to n do
if (map[x,i]>0) and (dist[x]+map[x,i]<dist[i]) and (flag[x,i]) then
begin
dist[i]:=dist[x]+map[x,i];
if not(vis[i]) then
begin
t:=t mod n+1;
q[t]:=i;
vis[i]:=true;
end;
end;
end;
end;
begin
assign(input,'pos1.in');assign(output,'output.txt');
reset(input);rewrite(output);
readln(n,m);
for i:=1 to n do readln(a[i].x,a[i].y);
fillchar(pre,sizeof(pre),0);
for i:=1 to n do
for j:=1 to n do
map[i,j]:=maxlongint;
for i:=1 to m do
begin
readln(x,y);
map[x,y]:=sqrt(sqr(a[x].x-a[y].x)+sqr(a[x].y-a[y].y));
map[y,x]:=sqrt(sqr(a[x].x-a[y].x)+sqr(a[x].y-a[y].y));
end;
spfa1;ans:=dist[n];
num:=n;max:=maxlongint;
while num<>0 do
begin
fillchar(flag,sizeof(flag),true);
flag[num,pre[num]]:=false;
flag[pre[num],num]:=false;
spfa2;
if (dist[n]<max) and (dist[n]>=ans) then max:=dist[n];
num:=pre[num];
end;
writeln(max:0:2);
close(input);close(output);
end.