#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 113;
const double eps = 1e-7;
struct pt {
  long double x, y;
  int ind;
  pt(long double x = 0, long double y = 0, int ind = 0)
      : x(x), y(y), ind(ind) {}
};
long double dist(pt a, pt b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
int n;
pt a, b, t, rat[N];
pt mnA[2], mnB[2];
int used[N];
long double ans = 1000000000000, newAns;
bool cnt1(pt x, pt y) {
  long double toX = sqrt(dist(a, x)) + sqrt(dist(t, y));
  long double toY = sqrt(dist(a, y)) + sqrt(dist(t, x));
  return (toX - toY < eps);
}
bool cnt2(pt x, pt y) {
  long double toX = sqrt(dist(b, x)) + sqrt(dist(t, y));
  long double toY = sqrt(dist(b, y)) + sqrt(dist(t, x));
  return (toX - toY < eps);
}
int main() {
  cout.precision(30);
  cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> rat[i].x >> rat[i].y;
    rat[i].ind = i;
  }
  sort(rat + 1, rat + n + 1, cnt1);
  mnA[0] = rat[1];
  mnA[1] = rat[2];
  sort(rat + 1, rat + n + 1, cnt2);
  mnB[0] = rat[1];
  mnB[1] = rat[2];
  if (n == 1) {
    ans = min(sqrt(dist(a, rat[1])), sqrt(dist(b, rat[1]))) +
          sqrt(dist(rat[1], t));
    cout << ans;
    return 0;
  }
  ans = sqrt(dist(a, mnA[0])) + sqrt(dist(mnA[0], t));
  used[mnA[0].ind] = 1;
  for (int i = 1; i <= n; i++) {
    if (used[rat[i].ind]) continue;
    ans += 2 * sqrt(dist(t, rat[i]));
  }
  memset(used, 0, sizeof(used));
  newAns = sqrt(dist(b, mnB[0])) + sqrt(dist(mnB[0], t));
  used[mnB[0].ind] = 1;
  for (int i = 1; i <= n; i++) {
    if (used[rat[i].ind]) continue;
    newAns += 2 * sqrt(dist(t, rat[i]));
  }
  ans = min(ans, newAns);
  memset(used, 0, sizeof(used));
  newAns = sqrt(dist(a, mnA[0])) + sqrt(dist(mnA[0], t));
  used[mnA[0].ind] = 1;
  if (used[mnB[0].ind]) {
    newAns += sqrt(dist(b, mnB[1])) + sqrt(dist(mnB[1], t));
    used[mnB[1].ind] = 1;
  } else {
    newAns += sqrt(dist(b, mnB[0])) + sqrt(dist(mnB[0], t));
    used[mnB[0].ind] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (used[rat[i].ind]) continue;
    newAns += 2 * sqrt(dist(t, rat[i]));
  }
  ans = min(ans, newAns);
  memset(used, 0, sizeof(used));
  newAns = sqrt(dist(b, mnB[0])) + sqrt(dist(mnB[0], t));
  used[mnB[0].ind] = 1;
  if (used[mnA[0].ind]) {
    newAns += sqrt(dist(a, mnA[1])) + sqrt(dist(mnA[1], t));
    used[mnA[1].ind] = 1;
  } else {
    newAns += sqrt(dist(a, mnA[0])) + sqrt(dist(mnA[0], t));
    used[mnA[0].ind] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (used[rat[i].ind]) continue;
    newAns += 2 * sqrt(dist(t, rat[i]));
  }
  ans = min(ans, newAns);
  cout << ans;
}
