#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long b, long long p) {
  if (p == 0) return 1;
  long long my = bigmod(b, p / 2);
  my *= my;
  my %= 1000000009;
  if (p & 1) my *= b, my %= 1000000009;
  return my;
}
int setb(int n, int pos) { return n = n | (1 << pos); }
int resb(int n, int pos) { return n = n & ~(1 << pos); }
bool checkb(int n, int pos) { return (bool)(n & (1 << pos)); }
struct point {
  double x, y;
  point(){};
  point(double _x, double _y) {
    x = _x;
    y = _y;
  }
};
point ara[100005], a, b, c;
long long n;
double d[3][100005];
double dist(point p1, point p2) {
  return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}
double dp[100005][3][3];
bool visit[100005][3][3];
double F(long long pos, long long f, long long s) {
  if (pos > n) {
    if (f == 0 && s == 0)
      return pow(2.0, 127.0);
    else
      return 0.0;
  }
  if (visit[pos][f][s]) return dp[pos][f][s];
  double ret = d[2][pos] + d[2][pos] + F(pos + 1, f, s);
  if (f == 0) ret = min(ret, d[0][pos] + d[2][pos] + F(pos + 1, 1, s));
  if (s == 0) ret = min(ret, d[1][pos] + d[2][pos] + F(pos + 1, f, 1));
  visit[pos][f][s] = 1;
  return dp[pos][f][s] = ret;
}
int main() {
  long long i;
  scanf("%lf %lf", &a.x, &a.y);
  scanf("%lf %lf", &b.x, &b.y);
  scanf("%lf %lf", &c.x, &c.y);
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lf %lf", &ara[i].x, &ara[i].y);
  for (i = 1; i <= n; i++) {
    d[0][i] = dist(ara[i], a);
    d[1][i] = dist(ara[i], b);
    d[2][i] = dist(ara[i], c);
  }
  printf("%.10f\n", F(1, 0, 0));
  return 0;
}
