#include <bits/stdc++.h>
using namespace std;
const long long INF = 4.5e18;
const long long MAX = 1e6 + 5;
const long long MOD = 1e9 + 7;
long long n;
double ax, ay, bx, by, tx, ty;
double xi[100010];
double yi[100010];
inline double dis(double a, double b) { return a * a + b * b; }
inline double disa(double a, double b) {
  return (a - ax) * (a - ax) + (b - ay) * (b - ay);
}
inline double disb(double a, double b) {
  return (a - bx) * (a - bx) + (b - by) * (b - by);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> ax >> ay >> bx >> by >> tx >> ty;
  ax -= tx;
  ay -= ty;
  bx -= tx;
  by -= ty;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> xi[i] >> yi[i];
    xi[i] -= tx;
    yi[i] -= ty;
  }
  if (n == 1) {
    cout << setprecision(30) << fixed
         << min(sqrt(disa(xi[0], yi[0])), sqrt(disb(xi[0], yi[0]))) +
                sqrt(dis(xi[0], yi[0]));
    return 0;
  }
  pair<double, long long> a1 = {INF, INF}, a2 = {INF, INF}, b1 = {INF, INF},
                          b2 = {INF, INF};
  for (int i = 0; i < n; i++) {
    pair<double, long long> nn = {
        sqrt(disa(xi[i], yi[i])) - sqrt(dis(xi[i], yi[i])), i};
    a2 = min(a2, nn);
    if (a2 < a1) swap(a1, a2);
    nn = {sqrt(disb(xi[i], yi[i])) - sqrt(dis(xi[i], yi[i])), i};
    b2 = min(b2, nn);
    if (b2 < b1) swap(b1, b2);
  }
  double ans = 0, ord1 = sqrt(disa(xi[a1.second], yi[a1.second])),
         ord2 = sqrt(disb(xi[b1.second], yi[b1.second]));
  for (int i = 0; i < n; i++) {
    double x = sqrt(dis(xi[i], yi[i]));
    if (i == a1.second)
      ord1 += x;
    else
      ord1 += x * 2;
    if (i == b1.second)
      ord2 += x;
    else
      ord2 += x * 2;
  }
  ans = min(ord1, ord2);
  if (a1.second != b1.second) {
    ;
    ord1 = sqrt(disa(xi[a1.second], yi[a1.second])) +
           sqrt(disb(xi[b1.second], yi[b1.second]));
    for (int i = 0; i < n; i++) {
      double x = sqrt(dis(xi[i], yi[i]));
      if (i == a1.second || i == b1.second)
        ord1 += x;
      else
        ord1 += x * 2;
    }
    ans = min(ans, ord1);
  } else {
    ;
    ;
    ord1 = sqrt(disa(xi[a1.second], yi[a1.second])) +
           sqrt(disb(xi[b2.second], yi[b2.second]));
    ;
    ;
    ;
    for (int i = 0; i < n; i++) {
      double x = sqrt(dis(xi[i], yi[i]));
      if (i == a1.second || i == b2.second)
        ord1 += x;
      else
        ord1 += x * 2;
    }
    ans = min(ans, ord1);
    ;
    ord1 = sqrt(disa(xi[a2.second], yi[a2.second])) +
           sqrt(disb(xi[b1.second], yi[b1.second]));
    for (int i = 0; i < n; i++) {
      double x = sqrt(dis(xi[i], yi[i]));
      if (i == a2.second || i == b1.second)
        ord1 += x;
      else
        ord1 += x * 2;
    }
    ans = min(ans, ord1);
  }
  cout << setprecision(30) << fixed << ans << '\n';
  return 0;
}
