#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  long long ax, ay, bx, by, tx, ty;
  cin >> ax >> ay >> bx >> by >> tx >> ty;
  int n;
  cin >> n;
  vector<pair<long long, long long> > v;
  vector<long double> dists, distA, distB;
  dists.push_back(0);
  distA.push_back(0);
  distB.push_back(0);
  long double sum = 0;
  for (int i = 1; i <= n; i++) {
    long long first, second;
    cin >> first >> second;
    v.push_back({first, second});
    dists.push_back(
        sqrtl((first - tx) * (first - tx) + (second - ty) * (second - ty)));
    distA.push_back(
        sqrtl((ax - first) * (ax - first) + (ay - second) * (ay - second)));
    distB.push_back(
        sqrtl((bx - first) * (bx - first) + (by - second) * (by - second)));
    sum += dists.back();
  }
  vector<long double> pref(n + 2), suf(n + 2);
  pref[1] = distA[1] - dists[1];
  suf[n] = distA[n] - dists[n];
  for (int i = 2; i <= n; i++) {
    pref[i] = min(pref[i - 1], distA[i] - dists[i]);
  }
  for (int i = n - 1; i >= 1; i--) {
    suf[i] = min(suf[i + 1], distA[i] - dists[i]);
  }
  long double ans = 1e18;
  sum *= 2;
  for (int i = 1; i <= n; i++) {
    long double cur = sum;
    cur += distA[i];
    cur -= dists[i];
    ans = min(ans, cur);
    cur = sum;
    cur += distB[i];
    cur -= dists[i];
    ans = min(ans, cur);
    long double best = 1e18;
    if (i != 1) {
      best = min(best, pref[i - 1]);
    }
    if (i != n) {
      best = min(best, suf[i + 1]);
    }
    if (best != 1e18) {
      cur += best;
      ans = min(ans, cur);
    }
  }
  cout << setprecision(10) << fixed << ans << "\n";
  return 0;
}
