#include using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) ((ll)(x).size()) #define len(x) ((ll)(x).length()) #define endl "\n" template struct Dijkstra { const T inf = numeric_limits::max() / 2 - 1; vector dist; vector path; Dijkstra() {} Dijkstra(int n) { graph.resize(n); dist.resize(n); prev.resize(n); } void add_edge(int from, int to, T cost) { graph[from].emplace_back(to, cost); } void get_distance(int from) { priority_queue, vector>, greater>> pq; fill(dist.begin(), dist.end(), inf); fill(prev.begin(), prev.end(), -1); dist[from] = 0; pq.push(make_pair(0, from)); while(!pq.empty()) { pair p = pq.top(); pq.pop(); if (dist[p.second] < p.first) continue; for (auto e : graph[p.second]) { if (dist[e.first] > (dist[p.second] + e.second)) { dist[e.first] = dist[p.second] + e.second; prev[e.first] = p.second; pq.push(make_pair(dist[e.first], e.first)); } } } } void get_path(int to) { path = vector(0); for (; to != -1; to = prev[to]) { path.push_back(to); } reverse(path.begin(), path.end()); } private: vector>> graph; vector prev; }; double get_dist(ll x1, ll y1, ll x2, ll y2) { ll dx = x1 - x2; ll dy = y1 - y2; return sqrt(dx * dx + dy * dy); } int main() { cin.tie(0); ios::sync_with_stdio(false); // ifstream in("input.txt"); // cin.rdbuf(in.rdbuf()); ll n, m, x, y; cin >> n >> m >> x >> y; x--; y--; vector> pos(n); rep(i, n) { ll p, q; cin >> p >> q; pos[i] = make_pair(p, q); } Dijkstra di(n); rep(i, m) { ll p, q; cin >> p >> q; p--; q--; double d = get_dist(pos[p].first, pos[p].second, pos[q].first, pos[q].second); di.add_edge(p, q, d); di.add_edge(q, p, d); } di.get_distance(x); printf("%.10f\n", di.dist[y]); return 0; }