rt
#include <bits/stdc++.h>
#define ll long long
#define N 100010
#define M 210
using namespace std;
int n, m, add_edge; bool bian[M][M];
double px[M], py[M], dis[M];
int head[M * M * 2], from[M], vis[M];
struct CCC {
int next, to; double dis;
}edge[M * M * 2];
struct node {
int x; double dis;
bool operator < (const node &b) const {
return dis > b.dis;
}
};
int read() {
int s = 0, f = 0; char ch = getchar();
while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
return f ? -s : s;
}
double distant(double x, double y, double a, double b) {
return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}
void add(int from, int to, double dis) {
edge[++add_edge].next = head[from];
edge[add_edge].to = to;
edge[add_edge].dis = dis;
head[from] = add_edge;
}
void dijkstra() {
for (int i = 1; i <= n; i++) dis[i] = 444444444444.00;
memset(vis, 0, sizeof vis);
priority_queue<node> q;
q.push((node){1, 0}), dis[1] = 0;
while (!q.empty()) {
node fr = q.top(); q.pop();
int x = fr.x;
if (vis[x]) continue;
vis[x] = 1;
for (int i = head[x]; i; i = edge[i].next) {
int to = edge[i].to;
if (bian[x][to]) continue;
if (!vis[to] && dis[to] > dis[x] + edge[i].dis) {
dis[to] = dis[x] + edge[i].dis; from[to] = x;
q.push((node){to, dis[to]});
}
}
}
}
int main() {
n = read(), m = read();
for (int i = 1; i <= n; i++)
px[i] = read(), py[i] = read();
for (int i = 1, x, y; i <= m; i++) {
x = read(), y = read();
double d = distant(px[x], py[x], px[y], py[y]);
add(x, y, d), add(y, x, d);
}
dijkstra();
double an = dis[n];
int sy = n; double ans = 444444444444.00;
while (sy != 1) {
bian[from[sy]][sy] = 1;
dijkstra();
if (dis[n] > an)
ans = min(ans, dis[n]);
bian[from[sy]][sy] = 0;
sy = from[sy];
}
if (ans == 444444444444.00) puts("-1");
else printf("%.2lf\n", ans);
}