#include <bits/stdc++.h>
using namespace std;
double find(double a, double b, double c, double d) {
  double ans = (a - c) * (a - c) + (b - d) * (b - d);
  ans = sqrt(ans);
  return ans;
}
bool byme(pair<double, pair<int, int> > a, pair<double, pair<int, int> > b) {
  return a.first > b.first;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  double x1, x2, y1, y2, a, b;
  cin >> x1 >> y1 >> x2 >> y2 >> a >> b;
  int n;
  cin >> n;
  double mp[n];
  pair<double, double> dp[n];
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    double ans = find(x, y, a, b);
    mp[i] = 2 * ans;
    ans = find(x1, y1, x, y) + find(x, y, a, b);
    dp[i].first = ans;
    ans = find(x2, y2, x, y) + find(x, y, a, b);
    dp[i].second = ans;
  }
  if (n == 1) {
    double ans1 = 0;
    ans1 = min(dp[0].first, dp[0].second);
    cout << setprecision(12) << ans1 << endl;
    return 0;
  }
  vector<pair<double, double> > ans;
  multiset<double> a1;
  multiset<double> b1;
  double cnt = 0;
  for (int i = 0; i < n; i++) {
    ans.push_back({mp[i] - dp[i].first, mp[i] - dp[i].second});
    cnt += mp[i];
    a1.insert(mp[i] - dp[i].first);
    b1.insert(mp[i] - dp[i].second);
  }
  double ans1 = INT_MIN;
  for (int i = 0; i < n; i++) {
    set<double>::iterator it;
    it = b1.find(ans[i].second);
    b1.erase(it);
    it = --(b1.end());
    ans1 = max(ans1, (*it + ans[i].first));
    ans1 = max(ans1, ans[i].first);
    b1.insert(ans[i].second);
    it = a1.find(ans[i].first);
    a1.erase(it);
    it = --(a1.end());
    ans1 = max(ans1, (*it + ans[i].second));
    a1.insert(ans[i].first);
    ans1 = max(ans1, ans[i].second);
  }
  cnt -= ans1;
  cout << setprecision(12) << cnt << endl;
  return 0;
}
