#include <bits/stdc++.h>
using namespace std;
double dist(double a, double b, double c, double d) {
  return sqrt((a - c) * (a - c) + (b - d) * (b - d));
}
int main() {
  double ax, ay, bx, by, cx, cy;
  long long n, i, j;
  cin >> ax >> ay >> bx >> by >> cx >> cy >> n;
  double x[n + 1], y[n + 1], sum, ans;
  vector<pair<double, long long> > a, b;
  for (i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    sum += 2 * dist(x[i], y[i], cx, cy);
    b.push_back(
        make_pair(dist(x[i], y[i], bx, by) - dist(x[i], y[i], cx, cy), i));
    a.push_back(
        make_pair(dist(x[i], y[i], ax, ay) - dist(x[i], y[i], cx, cy), i));
  }
  sort((a).begin(), (a).end());
  sort((b).begin(), (b).end());
  if (a[0].second == b[0].second) {
    ans = min(a[1].first + b[0].first, a[0].first + b[1].first);
    ans = min(ans, a[0].first);
    ans = min(ans, b[0].first);
  } else {
    ans = a[0].first + b[0].first;
    ans = min(ans, a[0].first);
    ans = min(ans, b[0].first);
  }
  sum += ans;
  printf("%.12f", sum);
  return 0;
}
