#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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Yi54KSooYS54LWIueCkgKyAoYS55LWIueSkqKGEueS1iLnkpKTsKICAgIHJldHVybiByZXM7Cn0KCi8vIGRvdWJsZSBQcmltKGludCBuKXsKLy8gICAgIHByaW9yaXR5X3F1ZXVlPFAsIHZlY3RvcjxQPiwgZ3JlYXRlcjxQPj4gcHE7Ci8vICAgICBwcS5wdXNoKHswLjAsMX0pOwovLyAgICAgZG91YmxlIGNvc3Q9MC4wOwovLyAgICAgd2hpbGUgKCFwcS5lbXB0eSgpKXsKLy8gICAgICAgICBkb3VibGUgdz0gcHEudG9wKCkuZmlyc3Q7Ci8vICAgICAgICAgaW50IHU9IHBxLnRvcCgpLnNlY29uZDsKLy8gICAgICAgICBwcS5wb3AoKTsKLy8gICAgICAgICBpZiAodmlzaXRlZFt1XSkgY29udGludWU7Ci8vICAgICAgICAgdmlzaXRlZFt1XT0xOwovLyAgICAgICAgIGNvc3QrPSB3OwoKLy8gICAgICAgICBmb3IgKGludCB2PTE7djw9bjt2KyspewovLyAgICAgICAgICAgICBpZiAoIXZpc2l0ZWRbdl0pewovLyAgICAgICAgICAgICAgICAgZG91YmxlIHdlPSBtYXRyaXhbdV1bdl07Ci8vICAgICAgICAgICAgICAgICBwcS5wdXNoKHt3ZSx2fSk7Ci8vICAgICAgICAgICAgIH0KLy8gICAgICAgICB9Ci8vICAgICB9Ci8vICAgICByZXR1cm4gY29zdDsKLy8gfQoKZG91YmxlIFByaW1OZXcoaW50IG4pewogICAgZG91YmxlIGRbTUFYTl07CiAgICBkb3VibGUgcmVzPTAuMDsKICAgIGZpbGwoZCsxLGQrbisxLElORik7CiAgICBkWzFdPTA7CiAgICB2aXNpdGVkWzFdPTE7CiAgICBpbnQgbkU9MDsKICAgIHdoaWxlICgxKXsKICAgICAgICBpbnQgdT0wOwogICAgICAgIGZvciAoaW50IGk9MTtpPD1uO2krKyl7CiAgICAgICAgICAgIGlmICghdmlzaXRlZFtpXSBhbmQgZFtpXTxkW3VdKSB1PWk7CiAgICAgICAgfQogICAgICAgIGlmICghdSkgYnJlYWs7CiAgICAgICAgdmlzaXRlZFt1XT0xOwogICAgICAgIHJlcys9IGRbdV07CiAgICAgICAgbkUrKzsKICAgICAgICBmb3IgKGludCB2PTE7djw9bjt2KyspewogICAgICAgICAgICBpZiAoIXZpc2l0ZWRbdl0gYW5kIGRbdl0+IG1hdHJpeFt1XVt2XSl7CiAgICAgICAgICAgICAgICBkW3ZdPW1hdHJpeFt1XVt2XTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGlmIChuRSA8IG4tMSkgcmV0dXJuIDAuMDsKICAgIHJldHVybiByZXM7Cn0KCmludCBtYWluKCkgewogICAgc2V0dXAoKTsKICAgIGludCBuOwogICAgY2luPj5uOwogICAgbXNldCh2aXNpdGVkKTsKICAgIGZvciAoaW50IGk9MTtpPD1uO2krKyl7CiAgICAgICAgY2luPj5veHlbaV0ueD4+b3h5W2ldLnk7CiAgICB9CiAgICBpbnQgbTsKICAgIGNpbj4+bTsKICAgIGZvciAoaW50IGk9MTtpPD1uO2krKyl7CiAgICAgICAgZm9yIChpbnQgaj0xO2o8PW47aisrKXsKICAgICAgICAgICAgaWYgKGkhPWopewogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdPWNhbGRpc3RhbmNpYShveHlbaV0sb3h5W2pdKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlewogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdPTAuMDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGZvciAoaW50IGk9MDtpPG07aSsrKXsKICAgICAgICBpbnQgdSx2OwogICAgICAgIGNpbj4+dT4+djsKICAgICAgICBtYXRyaXhbdV1bdl09bWF0cml4W3ZdW3VdPTAuMDsKICAgIH0KICAgIGNvdXQ8PGZpeGVkPDxzZXRwcmVjaXNpb24oMik8PFByaW1OZXcobik7Cn0K