#include <bits/stdc++.h>
using namespace std;
const double INF = 9e308;
const int MAXN = 1e5 + 10;
const int MOD = 1000000007;
double px[MAXN], py[MAXN], len[MAXN];
int a2, b2;
double dis(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
int main() {
  ios_base::sync_with_stdio(false);
  double lens = 0.0, minn = INF;
  int n;
  double ax, ay, bx, by, tx, ty;
  cin >> ax >> ay >> bx >> by >> tx >> ty;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> px[i] >> py[i];
    len[i] = dis(px[i], py[i], tx, ty);
  }
  for (int i = 0; i < n; i++) lens = lens + len[i] * 2;
  double maxa, maxb, maxaa, maxbb;
  double tmpa, tmpb;
  double tmplena, tmplenaa, tmplenb, tmplenbb;
  maxa = maxaa = maxb = maxbb = INF;
  for (int i = 0; i < n; i++) {
    tmplena = -dis(px[i], py[i], tx, ty) + dis(px[i], py[i], ax, ay);
    if (maxa > tmplena) {
      maxa = tmplena;
      tmpa = i;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == tmpa) continue;
    tmplenaa = -dis(px[i], py[i], tx, ty) + dis(px[i], py[i], ax, ay);
    if (maxaa > tmplenaa) {
      maxaa = tmplenaa;
    }
  }
  for (int i = 0; i < n; i++) {
    tmplenb = -dis(px[i], py[i], tx, ty) + dis(px[i], py[i], bx, by);
    if (maxb > tmplenb) {
      maxb = tmplenb;
      tmpb = i;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == tmpb) continue;
    tmplenbb = -dis(px[i], py[i], tx, ty) + dis(px[i], py[i], bx, by);
    if (maxbb > tmplenbb) {
      maxbb = tmplenbb;
    }
  }
  minn = lens + maxa;
  minn = min(minn, lens + maxb);
  if (tmpa != tmpb)
    minn = min(minn, lens + maxa + maxb);
  else {
    minn = min(minn, lens + maxa + maxbb);
    minn = min(minn, lens + maxb + maxaa);
  }
  printf("%.12lf\n", minn);
  return 0;
}
