#include <bits/stdc++.h>
using namespace std;
double make_dis(double x, double y, double a, double b) {
  return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}
const long long MAXn = 1e5 + 100;
const double INF = -1e18;
double x[MAXn], y[MAXn], ansa[MAXn], ansb[MAXn];
double ax, bx, ay, by, pointer1, pointer2, mxa = INF, mxb = INF, cnt, tx, ty,
                                           awns;
long long n;
signed main() {
  cin >> ax >> ay >> bx >> by >> tx >> ty >> n;
  double cnt = 0;
  for (long long i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    double ans = make_dis(x[i], y[i], tx, ty);
    cnt += ans;
    ansa[i] = ans - make_dis(x[i], y[i], ax, ay);
    ansb[i] = ans - make_dis(x[i], y[i], bx, by);
  }
  cnt *= 2;
  for (long long i = 0; i < n; ++i) {
    if (mxa < ansa[i]) mxa = ansa[i], pointer1 = i;
    if (mxb < ansb[i]) mxb = ansb[i], pointer2 = i;
  }
  double awns = max(mxa, mxb);
  for (long long i = 0; i < n; ++i) {
    if (i != pointer1) awns = max(awns, mxa + ansb[i]);
    if (i != pointer2) awns = max(awns, mxb + ansa[i]);
  }
  return cout << setprecision(20) << cnt - awns << endl, 0;
}
