#include <bits/stdc++.h>
using namespace std;
vector<int> vi;
const int mod = int(1e9) + 7, INF = 0x3fffffff;
const int maxn = 1e5 + 13;
long double A[maxn], B[maxn], T[maxn];
long double getd(long double ax, long double ay, long double bx,
                 long double by) {
  return sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay));
}
int main(void) {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long double ax, bx, ay, by, tx, ty;
  while (cin >> ax >> ay >> bx >> by >> tx >> ty) {
    int n;
    cin >> n;
    long double ans = 0;
    cout.precision(15);
    for (int i = 0; i < n; i++) {
      long double x, y;
      cin >> x >> y;
      T[i] = getd(tx, ty, x, y);
      ans += T[i] * 2;
      A[i] = getd(ax, ay, x, y);
      B[i] = getd(bx, by, x, y);
    }
    long double ag = 0, bg = 0;
    int la = -1, lb = -2;
    for (int i = 0; i < n; i++) {
      if (T[i] - A[i] > ag) {
        la = i;
        ag = T[i] - A[i];
      }
      if (T[i] - B[i] > bg) {
        lb = i;
        bg = T[i] - B[i];
      }
    }
    if (ag == 0 && bg == 0) {
      ag = -1e20;
      for (int i = 0; i < n; i++) {
        ag = max(ag, max(T[i] - A[i], T[i] - B[i]));
      }
      cout << ans - ag << endl;
    } else if (la != lb) {
      cout << ans - ag - bg << endl;
    } else {
      long double ok = 0;
      long double bgg = 0;
      for (int i = 0; i < n; i++) {
        if (i != la && T[i] - B[i] > bgg) {
          bgg = T[i] - B[i];
        }
      }
      ok = ag + bgg;
      bgg = 0;
      for (int i = 0; i < n; i++) {
        if (i != la && T[i] - A[i] > bgg) {
          bgg = T[i] - A[i];
        }
      }
      ok = max(ok, bg + bgg);
      cout << ans - ok << endl;
    }
  }
  return 0;
}
