#include <bits/stdc++.h>
using namespace std;
double dist(double a, double b, double c, double d) {
  return sqrt((a - c) * (a - c) + (b - d) * (b - d));
}
double disa[100100];
double disb[100100];
double dis[100100];
double disk[100100];
double Min1, Min2, ans;
int main() {
  double a, b, c, d, e, f;
  int n;
  double x, y;
  while (cin >> a >> b >> c >> d >> e >> f >> n) {
    double sum = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%lf %lf", &x, &y);
      disa[i] = dist(a, b, x, y);
      disb[i] = dist(c, d, x, y);
      dis[i] = dist(e, f, x, y);
      sum += dis[i];
    }
    sum *= 2.0;
    Min1 = Min2 = 1e19;
    for (int i = 1; i <= n; i++) {
      Min1 = min(Min1, disa[i] - dis[i]);
      Min2 = min(Min2, disb[i] - dis[i]);
    }
    ans = min(sum + Min1, sum + Min2);
    int id1 = -1, id2 = -1;
    Min1 = Min2 = 1e19;
    for (int i = 1; i <= n; i++) {
      if (disb[i] - dis[i] < Min1) {
        Min1 = disb[i] - dis[i];
        id1 = i;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (disa[i] - dis[i] < Min2 && (id1 != i)) {
        Min2 = disa[i] - dis[i];
        id2 = i;
      }
    }
    ans = min(ans, sum + Min1 + Min2);
    Min1 = Min2 = 1e19;
    for (int i = 1; i <= n; i++) {
      if (disa[i] - dis[i] < Min1) {
        Min1 = disa[i] - dis[i];
        id1 = i;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (disb[i] - dis[i] < Min2 && (id1 != i)) {
        Min2 = disb[i] - dis[i];
        id2 = i;
      }
    }
    ans = min(ans, sum + Min1 + Min2);
    printf("%.10f\n", ans);
  }
  return 0;
}
