#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
double ed(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(0);
  cin.tie(0);
  double ax, ay, bx, by, tx, ty;
  int n;
  cin >> ax >> ay >> bx >> by >> tx >> ty >> n;
  double td = 0;
  vector<pair<double, int>> p1(n), p2(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    td += 2 * ed(x, y, tx, ty);
    p1[i] = {ed(x, y, ax, ay) - ed(x, y, tx, ty), i};
    p2[i] = {ed(x, y, bx, by) - ed(x, y, tx, ty), i};
  }
  sort(p1.begin(), p1.end());
  sort(p2.begin(), p2.end());
  double ans = min(td + p1[0].first, td + p2[0].first);
  if (n == 1) {
    cout << setprecision(12) << ans;
    return 0;
  }
  if (p1[0].second != p2[0].second) {
    ans = min(ans, td + p1[0].first + p2[0].first);
  } else {
    ans = min(ans, min(td + p1[0].first + p2[1].first,
                       td + p1[1].first + p2[0].first));
  }
  cout << setprecision(12) << ans;
  return 0;
}
