#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int mod = 1000000007;
const double PI = acos(-1.0);
struct node {
  double x, y;
} a, b, c[100500], m;
char s[100500];
int dp[100500];
bool vis[100500];
int n;
double ans;
double f(node a, node b) {
  return sqrt((a.x - b.x) * 1.0 * (a.x - b.x) +
              (a.y - b.y) * 1.0 * (a.y - b.y));
}
int main() {
  int t, ca = 1;
  int p, q;
  scanf("%lf %lf %lf %lf %lf %lf", &a.x, &a.y, &b.x, &b.y, &m.x, &m.y);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lf %lf", &c[i].x, &c[i].y);
    ans += f(c[i], m) * 2;
  }
  double sum = ans;
  ans = 1e18;
  double res = 1e18;
  p = -1;
  q = -1;
  for (int i = 0; i < n; i++) {
    if (f(c[i], a) - f(c[i], m) + sum < res) {
      res = f(c[i], a) - f(c[i], m) + sum;
      p = i;
    }
  }
  ans = min(ans, res);
  double res1 = 1e18;
  for (int i = 0; i < n; i++) {
    if (i == p) continue;
    if (f(c[i], b) - f(c[i], m) + res < res1) {
      res1 = f(c[i], b) - f(c[i], m) + res;
      q = i;
    }
  }
  ans = min(ans, res1);
  p = -1;
  q = -1;
  res = 1e18;
  for (int i = 0; i < n; i++) {
    if (f(c[i], b) - f(c[i], m) + sum < res) {
      res = f(c[i], b) - f(c[i], m) + sum;
      q = i;
    }
  }
  ans = min(ans, res);
  res1 = 1e18;
  for (int i = 0; i < n; i++) {
    if (i == q) continue;
    if (f(c[i], a) - f(c[i], m) + res < res1) {
      res1 = f(c[i], a) - f(c[i], m) + res;
      p = i;
    }
  }
  ans = min(ans, res1);
  printf("%.12lf\n", ans);
  return 0;
}
