#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    double ax, ay, bx, by, cx, cy, ans, cnt;
    cin >> ax >> ay >> bx >> by >> cx >> cy;
    std::vector<pair<double, long long int>> a, b;
    long long int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      double x, y;
      cin >> x >> y;
      double p, q, r, s;
      p = (cx - x) * (cx - x) + (cy - y) * (cy - y);
      p = sqrt(p);
      cnt += p;
      q = (ax - x) * (ax - x) + (ay - y) * (ay - y);
      q = sqrt(q);
      r = (bx - x) * (bx - x) + (by - y) * (by - y);
      r = sqrt(r);
      a.push_back({p - q, i + 1});
      b.push_back({p - r, i + 1});
    }
    cnt *= 2;
    sort((a).begin(), (a).end());
    sort((b).begin(), (b).end());
    if (n == 1) {
      ans = min(cnt - a[0].first, cnt - b[0].first);
      cout << setprecision(12) << ans;
      return 0;
    } else {
      ans = cnt - a[n - 1].first;
      ans = min(ans, cnt - b[n - 1].first);
      if (a[n - 1].second != b[n - 1].second)
        ans = min(ans, cnt - a[n - 1].first - b[n - 1].first);
      else {
        ans = min(ans, min(cnt - a[n - 1].first - b[n - 2].first,
                           cnt - a[n - 2].first - b[n - 1].first));
      }
    }
    cout << setprecision(12) << ans;
  }
  return 0;
}
