#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = (int)1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 1e6 + 5;
int Kx, Ky, Cx, Cy, Tx, Ty, n, x, y;
double pre[N], suff[N], add[N], all;
double dist(int x, int y, int a, int b) {
  return sqrt((long long)(x - a) * (x - a) + (long long)(y - b) * (y - b));
}
int main() {
  scanf("%d %d %d %d %d %d", &Kx, &Ky, &Cx, &Cy, &Tx, &Ty);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &x, &y);
    double add = dist(Tx, Ty, x, y);
    all += add * 2;
    suff[i] = pre[i] = dist(Cx, Cy, x, y) - add;
    ::add[i] = dist(Kx, Ky, x, y) - add;
  }
  pre[0] = suff[n + 1] = linf;
  for (int i = 1; i <= n; i++) {
    pre[i] = min(pre[i - 1], pre[i]);
  }
  for (int i = n; i >= 1; i--) {
    suff[i] = min(suff[i + 1], suff[i]);
  }
  double ans = suff[1] + all;
  for (int i = 1; i <= n; i++)
    ans = min(ans, all + min(0.0, min(pre[i - 1], suff[i + 1])) + add[i]);
  printf("%.12lf\n", ans);
  return 0;
}
