#include <bits/stdc++.h>
using namespace std;
double dist(int64_t x1, int64_t y1, int64_t x2, int64_t y2) {
  return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
ostream& operator<<(ostream& s, const std::pair<double, int>& p) {
  s << "(";
  s << p.first;
  s << ", ";
  s << p.second;
  s << ")";
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  int ax, ay, bx, by, tx, ty;
  int n;
  std::vector<std::pair<int, int>> bottles;
  cin >> ax >> ay >> bx >> by >> tx >> ty;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    bottles.push_back({x, y});
  }
  if (n == 0) {
    cout << "0";
  } else if (n == 1) {
    double ra = dist(ax, ay, bottles[0].first, bottles[0].second);
    double rb = dist(bx, by, bottles[0].first, bottles[0].second);
    double rt = dist(tx, ty, bottles[0].first, bottles[0].second);
    cout << fixed << setprecision(10) << (ra < rb ? ra : rb) + rt;
  } else {
    double total = 0;
    double T = 0;
    std::vector<std::pair<double, int>> A;
    std::vector<std::pair<double, int>> B;
    for (int i = 0; i < bottles.size(); i++) {
      double ra = dist(ax, ay, bottles[i].first, bottles[i].second);
      double rb = dist(bx, by, bottles[i].first, bottles[i].second);
      double rt = dist(tx, ty, bottles[i].first, bottles[i].second);
      T += 2 * rt;
      A.push_back({ra - rt, i});
      B.push_back({rb - rt, i});
    }
    A.push_back({0, -1});
    B.push_back({0, -1});
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    double add = 1e15;
    for (int i = 0; i < min(A.size(), (size_t)5); i++) {
      for (int j = 0; j < min(B.size(), (size_t)5); j++) {
        if (A[i].second != B[j].second) add = min(add, A[i].first + B[j].first);
      }
    }
    std::cout << fixed << setprecision(10) << T + add;
  }
  return 0;
}
