from heapq import heappush, heappop import math INF = float('inf') N, M = map(int, input().split()) X, Y = map(int, input().split()) p = [list(map(int, input().split())) for _ in range(N)] adj = [[] for _ in range(N)] for i in range(M): P, Q = map(int, input().split()) x1, y1 = p[P-1] x2, y2 = p[Q-1] adj[P-1].append((Q-1, math.sqrt((x1-x2)**2+(y1-y2)**2))) adj[Q-1].append((P-1, math.sqrt((x1-x2)**2+(y1-y2)**2))) def dijkstra(s, n): dist = [INF] * n hq = [(0, s)] dist[s] = 0 seen = [False] * n while hq: v = heappop(hq)[1] seen[v] = True for to, cost in adj[v]: if seen[to] == False and dist[v] + cost < dist[to]: dist[to] = dist[v] + cost heappush(hq, (dist[to], to)) return dist d = dijkstra(X-1, N) print(d[Y-1])