#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
struct node {
  double d;
  int num;
  bool operator<(const node &r) const { return d > r.d; }
} a[maxn], b[maxn];
double dist(double x1, double y1, double x2, double y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
int main() {
  double ax, ay, bx, by, tx, ty;
  scanf("%lf %lf %lf %lf %lf %lf", &ax, &ay, &bx, &by, &tx, &ty);
  int n;
  scanf("%d", &n);
  double ans = 0;
  for (int i = 1; i <= n; i++) {
    double x, y;
    scanf("%lf %lf", &x, &y);
    double d = sqrt(dist(x, y, tx, ty));
    ans += 2 * d;
    double d1 = d - sqrt(dist(x, y, ax, ay));
    double d2 = d - sqrt(dist(x, y, bx, by));
    a[i].d = d1;
    a[i].num = i;
    b[i].d = d2;
    b[i].num = i;
  }
  sort(a + 1, a + 1 + n);
  sort(b + 1, b + 1 + n);
  if (a[1].d <= 0 && b[1].d <= 0)
    ans -= max(a[1].d, b[1].d);
  else if (a[1].d * b[1].d < 0)
    ans -= max(a[1].d, b[1].d);
  else if (a[1].num != b[1].num)
    ans -= a[1].d + b[1].d;
  else {
    if (a[2].d <= 0 && b[2].d <= 0)
      ans -= max(a[1].d, b[1].d);
    else if (a[2].d <= 0)
      ans -= max(a[1].d + b[2].d, b[1].d);
    else if (b[2].d <= 0)
      ans -= max(a[1].d, b[1].d + a[2].d);
    else
      ans -= max(a[1].d + b[2].d, a[2].d + b[1].d);
  }
  printf("%.7lf\n", ans);
}
