#include <bits/stdc++.h>
using namespace std;
const int N = 100004;
double x[N], y[N], xa, xb, ya, yb, xz, yz, d[N], da[N], db[N], s[N];
double dis(double xa, double ya, double xb, double yb) {
  return sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
}
pair<double, int> pa[N], pb[N];
int main() {
  scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &xb, &yb, &xz, &yz);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf %lf", &x[i], &y[i]);
    d[i] = dis(x[i], y[i], xz, yz);
    da[i] = dis(x[i], y[i], xa, ya);
    db[i] = dis(x[i], y[i], xb, yb);
    pa[i] = pair<double, int>(da[i] - d[i], i);
    pb[i] = pair<double, int>(db[i] - d[i], i);
    s[i] = s[i - 1] + d[i];
  }
  double ans = 0x3f3f3f3f3f3f3f;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, s[n] * 2 - d[i] + min(db[i], da[i]));
  }
  sort(pa + 1, pa + n + 1);
  sort(pb + 1, pb + n + 1);
  if (n > 1) {
    if (pa[1].second != pb[1].second) {
      ans = min(ans, s[n] * 2 + pa[1].first + pb[1].first);
    } else {
      double t =
          s[n] * 2 + min(pa[1].first + pb[2].first, pa[2].first + pb[1].first);
      ans = min(ans, t);
    }
  }
  printf("%.12f\n", ans);
}
