#include <bits/stdc++.h>
using namespace std;
double dist(long long int a, long long int b, long long int c,
            long long int d) {
  return sqrt(((a - c) * (a - c)) + (b - d) * (b - d));
}
struct p {
  double val;
  long long int index;
};
int comp(const void* a, const void* b) {
  if (((struct p*)a)->val - ((struct p*)b)->val < 0) return -1;
  if (((struct p*)a)->val - ((struct p*)b)->val > 0) return 1;
  if (((struct p*)a)->val - ((struct p*)b)->val == 0) return 0;
}
int main() {
  long long int ax, ay, bx, by, tx, ty, n;
  cin >> ax;
  cin >> ay;
  cin >> bx;
  cin >> by;
  cin >> tx;
  cin >> ty;
  cin >> n;
  long long int i, x, y;
  struct p a[n], b[n], c[n];
  double sum = 0;
  for (i = 0; i < n; i++) {
    cin >> x;
    cin >> y;
    sum += 2 * dist(tx, ty, x, y);
    a[i].val = dist(ax, ay, x, y) - dist(tx, ty, x, y);
    a[i].index = i;
    b[i].val = dist(bx, by, x, y) - dist(tx, ty, x, y);
    b[i].index = i;
  }
  qsort(a, n, sizeof(struct p), comp);
  qsort(b, n, sizeof(struct p), comp);
  if (a[0].index == b[0].index) {
    sum += min(a[0].val,
               min(b[0].val, min(a[0].val + b[1].val, b[0].val + a[1].val)));
  } else {
    if (a[0].val < b[0].val) {
      sum += a[0].val;
      if (b[0].val < 0) sum += b[0].val;
    } else {
      sum += b[0].val;
      if (a[0].val < 0) sum += a[0].val;
    }
  }
  cout << setprecision(12) << fixed << sum << endl;
  return 0;
}
