#include <bits/stdc++.h>
using namespace std;
vector<pair<long double, int> > v1, v2;
long double dist(int a, int b, int c, int d) {
  long double ans = sqrt(1LL * (a - c) * (a - c) + 1LL * (b - d) * (b - d));
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  int ax, ay, bx, by, tx, ty, n, i;
  cin >> ax >> ay >> bx >> by >> tx >> ty >> n;
  long double ans = 0.00;
  for (i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    long double d1 = dist(ax, ay, x, y);
    long double d2 = dist(bx, by, x, y);
    long double d3 = dist(tx, ty, x, y);
    ans += 2.000000000 * d3;
    v1.push_back(make_pair(d1 - d3, i));
    v2.push_back(make_pair(d2 - d3, i));
    if (n == 1) {
      ans = min(d1, d2) + d3;
      cout << fixed << setprecision(15) << ans;
      return 0;
    }
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  long double temp = 1e18;
  if (v1[0].second == v2[0].second) {
    temp = min(v1[0].first + v2[1].first, temp);
    temp = min(v1[0].first, temp);
    temp = min(v2[0].first, temp);
    temp = min(v2[0].first + v1[1].first, temp);
  } else {
    temp = min(v1[0].first, temp);
    temp = min(v2[0].first, temp);
    temp = min(v1[0].first + v2[0].first, temp);
  }
  ans += temp;
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}
