import sys import heapq sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) class Dijkstra_list(): # 1-based def __init__(self,N): self.N = N self.edges = [[] for _ in range(N+1)] def add(self, u, v, d, directed=False): if directed is False: # 無向グラフの場合 self.edges[u].append((v,d)) self.edges[v].append((u,d)) else: # 有向グラフの場合 self.edges[u].append((v,d)) def delete(self, u, v): self.edges[u] = [_ for _ in self.edges[u] if _[0] != v] self.edges[v] = [_ for _ in self.edges[v] if _[0] != u] def search(self, s): # sから各頂点までの最短距離 inf = 10**18 dist = [inf]*(self.N+1) dist[s] = 0 q = [] heapq.heappush(q, (0, s)) v = [0]*(self.N+1) while q: k, u = heapq.heappop(q) if v[u]: continue v[u] = 1 for uv, ud in self.edges[u]: if v[uv]: continue vd = k + ud if dist[uv] > vd: dist[uv] = vd heapq.heappush(q, (vd, uv)) return dist N,M = MI() X,Y = MI() pos = [(0,0)]+[tuple(MI()) for _ in range(N)] Di = Dijkstra_list(N) for _ in range(M): P,Q = MI() x0,y0 = pos[P] x1,y1 = pos[Q] d = ((x0-x1)**2+(y0-y1)**2)**.5 Di.add(P,Q,d,directed=False) dist = Di.search(X) ans = dist[Y] print(ans)