#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
struct point {
  double x, y;
} p[maxn], a, b, t;
double dis(point a, point b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
double d[maxn];
int main() {
  int n;
  scanf("%lf%lf%lf%lf%lf%lf", &a.x, &a.y, &b.x, &b.y, &t.x, &t.y);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf%lf", &p[i].x, &p[i].y);
    d[i] = dis(p[i], t);
  }
  double l = dis(p[1], t);
  double disa = dis(p[1], a) + l;
  double disb = dis(p[1], b) + l;
  double disc = min(disa, disb);
  double sum = l * 2;
  for (int i = 2; i <= n; i++) {
    l = dis(p[i], t);
    disc = min(min(disc + 2 * l, disa + dis(p[i], b) + l),
               disb + dis(p[i], a) + l);
    disa = min(disa + 2 * l, sum + dis(a, p[i]) + l);
    disb = min(disb + 2 * l, sum + dis(b, p[i]) + l);
    sum += (2 * l);
  }
  printf("%.12lf", min(min(disa, disb), disc));
  return 0;
}
