import sys import numpy as np from scipy.linalg import norm from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix input = sys.stdin.buffer.readline int1 = lambda x: int(x) - 1 def main(): N, M = map(int, input().split()) X, Y = map(int1, input().split()) pole = np.array([tuple(map(int, input().split())) for _ in range(N)]) wire = np.array([tuple(map(int1, input().split())) for _ in range(M)]).T length = norm(pole[wire[0]] - pole[wire[1]], axis=1) matr = csr_matrix((length, wire), shape=(N, N)) print(dijkstra(matr, indices=X, directed=False)[Y]) if __name__ == '__main__': main()