#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
double ax, ay, bx, by, tx, ty;
double dis(double x0, double y0, double x1, double y1) {
  return sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1));
}
double a[N], b[N], c[N];
int main() {
  int n;
  double px, py;
  while (scanf("%lf%lf", &ax, &ay) != EOF) {
    scanf("%lf%lf%lf%lf", &bx, &by, &tx, &ty);
    scanf("%d", &n);
    double sum = 0, ans = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%lf%lf", &px, &py);
      double v = dis(px, py, tx, ty);
      a[i] = dis(bx, by, px, py) - v;
      b[i] = dis(ax, ay, px, py) - v;
      c[i] = a[i];
      ans += 2 * v;
    }
    a[0] = 1e19;
    c[n + 1] = 1e19;
    for (int i = 1; i <= n; i++) a[i] = min(a[i], a[i - 1]);
    for (int i = n; i >= 1; i--) {
      c[i] = min(c[i + 1], c[i]);
    }
    sum = c[1] + ans;
    for (int i = 1; i <= n; i++)
      sum = min(sum, ans + b[i] + min(0.0, min(a[i - 1], c[i + 1])));
    printf("%lf\n", sum);
  }
  return 0;
}
