#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 6;
int n;
long long ax, ay, bx, by, tx, ty;
long long x[MAXN], y[MAXN];
pair<double, int> dda[MAXN], ddb[MAXN];
double dist(long long asdasf, long long asdasfa, long long asdasfb = 0,
            long long asdasfc = 0) {
  return sqrt((asdasf - asdasfb) * (asdasf - asdasfb) +
              (asdasfa - asdasfc) * (asdasfa - asdasfc));
}
int main() {
  scanf("%lld", &ax), scanf("%lld", &ay);
  ;
  scanf("%lld", &bx), scanf("%lld", &by);
  ;
  scanf("%lld", &tx), scanf("%lld", &ty);
  ;
  ax -= tx;
  ay -= ty;
  bx -= tx;
  by -= ty;
  scanf("%d", &n);
  for (int i = 0; i < (int)n; i++) {
    scanf("%lld", &x[i]), scanf("%lld", &y[i]);
    ;
    x[i] -= tx;
    y[i] -= ty;
  }
  double sum2d = 0;
  for (int i = 0; i < (int)n; i++) {
    sum2d += 2 * dist(x[i], y[i]);
    dda[i] = {dist(x[i], y[i], ax, ay) - dist(x[i], y[i]), i};
    ddb[i] = {dist(x[i], y[i], bx, by) - dist(x[i], y[i]), i};
  }
  sort(dda, dda + n);
  sort(ddb, ddb + n);
  double ans = min(sum2d + dda[0].first, sum2d + ddb[0].first);
  if (n >= 2) {
    for (int i = 0; i < (int)2; i++)
      for (int j = 0; j < (int)2; j++) {
        if (dda[i].second == ddb[j].second) continue;
        ans = min(ans, sum2d + dda[i].first + ddb[j].first);
      }
  }
  printf("%.12lf\n", ans);
}
