from heapq import heappop, heappush from math import inf, sqrt from operator import ne class Point: def __init__(self, x, y) -> None: self.x = x self.y = y def distance_to(self, __o: object): if not isinstance(__o, Point): raise ValueError return sqrt((self.x - __o.x)**2 + (self.y - __o.y)**2) def main(): N, M = map(int, input().split()) X, Y = map(int, input().split()) X -= 1 Y -= 1 nodes = [Point(*map(int, input().split())) for _ in range(N)] weights = [{} for _ in range(N)] for _ in range(M): start, end = map(int, input().split()) weights[start-1][end-1] = nodes[start-1].distance_to(nodes[end-1]) weights[end-1][start-1] = weights[start-1][end-1] unvisited = set(idx for idx in range(N)) searched = [] heappush(searched, (0, X)) costs = [inf for _ in range(N)] decided = set() while searched: current_cost, next_node_idx = heappop(searched) if next_node_idx in decided: continue costs[next_node_idx] = current_cost decided.add(next_node_idx) for dest_idx, distance in weights[next_node_idx].items(): heappush(searched, (current_cost + distance, dest_idx)) print(costs[Y]) if __name__ == "__main__": main()