#include <bits/stdc++.h>
using namespace std;
double Far[100007], ans, Sum, Adil[100007], Right[100007], Left[100007],
    Point[100007][2], ax, ay, bx, by, tx, ty;
double Dist(double ax, double ay, double bx, double by) {
  return sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> ax >> ay >> bx >> by >> tx >> ty;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> Point[i][0] >> Point[i][1];
    Far[i] = Dist(Point[i][0], Point[i][1], tx, ty);
    Sum += Far[i];
  }
  Sum *= (double)2;
  ans = 1e20;
  for (long long i = 1; i <= n; ++i) {
    Adil[i] = Sum - Far[i] + Dist(ax, ay, Point[i][0], Point[i][1]);
    ans = min(ans, Adil[i]);
  }
  Left[0] = Left[n + 1] = Right[1 + n] = Right[0] = 1e20;
  for (long long i = 1, j = n; i <= n; ++i, --j) {
    Left[i] = min(Adil[i], Left[i - 1]);
    Right[j] = min(Adil[j], Right[j + 1]);
  }
  for (long long i = 1; i <= n; ++i) {
    ans = min(ans, min(Left[i - 1], Right[i + 1]) +
                       Dist(bx, by, Point[i][0], Point[i][1]) - Far[i]);
    ans = min(ans, Sum - Far[i] + Dist(bx, by, Point[i][0], Point[i][1]));
  }
  cout << std::setprecision(14) << ans << "\n";
  return 0;
}
