#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = (int)1e9 + 7;
const int inf = 1e9;
const int N = 1e6 + 5;
double add[N], pre[N], suf[N], all = 0.0;
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() {
  int ax, ay, bx, by, tx, ty, n, i;
  int x, y;
  cin >> ax >> ay >> bx >> by >> tx >> ty;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    double add = dist(tx, ty, x, y);
    all = all + 2 * add;
    pre[i] = suf[i] = dist(bx, by, x, y) - add;
    ::add[i] = dist(ax, ay, x, y) - add;
  }
  pre[0] = suf[n + 1] = linf;
  for (i = 1; i <= n; i++) pre[i] = min(pre[i - 1], pre[i]);
  for (i = n; i >= 1; i--) suf[i] = min(suf[i + 1], suf[i]);
  double ans = all + suf[1];
  for (i = 1; i <= n; i++)
    ans = min(ans, all + min(0.0, min(pre[i - 1], suf[i + 1])) + add[i]);
  printf("%.012f\n", ans);
  return 0;
}
