#include <bits/stdc++.h>
using namespace std;
pair<long double, long double> a, b, r, p[100005];
int n, e = 0, pos;
long double fr[100005], fa[100005], fb[100000], sm = 0, res, ra, rb, y, w;
long double far(pair<long double, long double> f,
                pair<long double, long double> s) {
  return sqrt((f.first - s.first) * (f.first - s.first) +
              (f.second - s.second) * (f.second - s.second));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> a.first >> a.second >> b.first >> b.second >> r.first >> r.second >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
    fr[i] = far(r, p[i]);
    fa[i] = far(a, p[i]);
    fb[i] = far(b, p[i]);
    sm += (fr[i] + fr[i]);
  }
  ra = sm - fr[0] + fa[0], e = 0, pos = 0;
  rb = sm - fr[0] + fb[0];
  for (int i = 1; i < n; i++) {
    if (ra > sm - fr[i] + fa[i]) e = i, ra = sm - fr[i] + fa[i];
    if (rb > sm - fr[i] + fb[i]) pos = i, rb = sm - fr[i] + fb[i];
  }
  res = min(ra, rb);
  y = ra;
  w = rb;
  for (int i = 0; i < n; i++) {
    if (i != pos) ra = min(ra, w - fr[i] + fa[i]);
    if (i != e) rb = min(rb, y - fr[i] + fb[i]);
  }
  res = min(res, min(ra, rb));
  cout << setprecision(12) << res << endl;
  return 0;
}
