#include <bits/stdc++.h>
using namespace std;
double a[100100], b[100100];
double dis(double x, double y, double c, double d) {
  return (sqrt((x - c) * (x - c) * 1.0 + (y - d) * (y - d) * 1.0));
}
int main() {
  int n;
  double x1, x2, y1, y2, x3, y3, x, y;
  cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  cin >> n;
  double ans = 0;
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  double a1max = -1e10, a2max = -1e10, b1max = -1e10, b2max = -1e10;
  double a1flag, a2flag, b1flag, b2flag;
  for (int i = 0; i < n; i++) {
    double distc = dis(a[i], b[i], x3, y3);
    double dista = distc - dis(a[i], b[i], x1, y1);
    double distb = distc - dis(a[i], b[i], x2, y2);
    if (dista > a1max) {
      a2max = a1max, a2flag = a1flag;
      a1max = dista, a1flag = i;
    } else if (dista > a2max) {
      a2flag = i, a2max = dista;
    }
    if (distb > b1max) {
      b2max = b1max, b2flag = b1flag;
      b1max = distb, b1flag = i;
    } else if (distb > b2max) {
      b2flag = i, b2max = distb;
    }
    ans += 2 * distc;
  }
  if (n == 1)
    ans = ans - max(b1max, a1max);
  else {
    if (a1flag != b1flag) {
      ans = min(min(ans - a1max - b1max, ans - a1max), ans - b1max);
    } else {
      ans = min(min(ans - max(a1max + b2max, a2max + b1max), ans - a1max),
                ans - b1max);
    }
  }
  printf("%.12lf\n", ans);
  return (0);
}
