#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int N = (int)1e6 + 7, mod = 1000000007;
const long long M = 2e15;
double ans, ax, ay, bx, by, cx, cy, t1, t2, a[N], b[N];
int n;
vector<pair<double, int> > x, y;
int main() {
  cin >> ax >> ay >> bx >> by >> cx >> cy >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lf%lf", a + i, b + i);
    t1 = sqrt((a[i] - cx) * (a[i] - cx) + (b[i] - cy) * (b[i] - cy));
    ans += t1 * 2;
    t2 = sqrt((a[i] - ax) * (a[i] - ax) + (b[i] - ay) * (b[i] - ay));
    x.push_back({t2 - t1, i});
    t2 = sqrt((a[i] - bx) * (a[i] - bx) + (b[i] - by) * (b[i] - by));
    y.push_back({t2 - t1, i});
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if (x[0].second == y[0].second) {
    if (n > 1)
      ans += min(y[0].first + min(0.0, x[1].first),
                 x[0].first + min(0.0, y[1].first));
    else
      ans += min(x[0].first, y[0].first);
  } else
    ans += min(min(0.0, x[0].first) + y[0].first,
               min(0.0, y[0].first) + x[0].first);
  printf("%.12f", ans);
  return 0;
}
