n,m=map(int,input().split()) S,G=map(int,input().split()) S-=1 G-=1 p=[tuple(map(int,input().split())) for i in range(n)] e=[] for i in range(m): s,g=map(int,input().split()) s-=1 g-=1 sx,sy=p[s] gx,gy=p[g] d=((sx-gx)**2+(sy-gy)**2)**0.5 e+=[(d,s,g)] e.sort() def root(x): p=x l=[p] while r[p]!=p: p=r[p] l+=[p] for p in l: r[p]=l[-1] return r[x] def union(x,y): rx=root(x) ry=root(y) if rx==ry: return if rx>ry: rx,ry=ry,rx r[ry]=rx return r=list(range(n)) C=0 for c,s,g in e: if root(s)!=root(g): union(s,g) C+=c if root(S)==root(G): break print(C)