#include <bits/stdc++.h>
#define el '\n'
#define FNAME "NAME"
#define allof(x) x.begin(),x.end()
#define mset(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;
const long long MOD = (long long) 1e9+7;
void setup(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	if (fopen(FNAME".inp","r")) {
		freopen(FNAME".inp","r",stdin);
		freopen(FNAME".out","w",stdout);
	}
}

void timer(){
    cerr << "Time run: " << 1000*clock()/CLOCKS_PER_SEC << "ms";
}

const int MAXN= 5005;
const double INF= DBL_MAX;
typedef pair<double, int> P;
struct Cordinate{
    int x,y;
} oxy[MAXN];

double matrix[MAXN][MAXN];

int visited[MAXN];

double caldistancia(Cordinate &a, Cordinate &b){
    double res= sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
    return res;
}

// double Prim(int n){
//     priority_queue<P, vector<P>, greater<P>> pq;
//     pq.push({0.0,1});
//     double cost=0.0;
//     while (!pq.empty()){
//         double w= pq.top().first;
//         int u= pq.top().second;
//         pq.pop();
//         if (visited[u]) continue;
//         visited[u]=1;
//         cost+= w;

//         for (int v=1;v<=n;v++){
//             if (!visited[v]){
//                 double we= matrix[u][v];
//                 pq.push({we,v});
//             }
//         }
//     }
//     return cost;
// }

double PrimNew(int n){
    double d[MAXN];
    double res=0.0;
    fill(d+1,d+n+1,INF);
    d[1]=0;
    visited[1]=1;
    int nE=0;
    while (1){
        int u=0;
        for (int i=1;i<=n;i++){
            if (!visited[i] and d[i]<d[u]) u=i;
        }
        if (!u) break;
        visited[u]=1;
        res+= d[u];
        nE++;
        for (int v=1;v<=n;v++){
            if (!visited[v] and d[v]> matrix[u][v]){
                d[v]=matrix[u][v];
            }
        }
    }
    if (nE < n-1) return 0.0;
    return res;
}

int main() {
    setup();
    int n;
    cin>>n;
    mset(visited);
    for (int i=1;i<=n;i++){
        cin>>oxy[i].x>>oxy[i].y;
    }
    int m;
    cin>>m;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            if (i!=j){
                matrix[i][j]=caldistancia(oxy[i],oxy[j]);
            }
            else{
                matrix[i][j]=0.0;
            }
        }
    }
    for (int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        matrix[u][v]=matrix[v][u]=0.0;
    }
    cout<<fixed<<setprecision(2)<<PrimNew(n);
}
