#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  double ax, ay, bx, by, tx, ty, x, y, ans = 0, temp;
  int n;
  cin >> ax >> ay >> bx >> by >> tx >> ty >> n;
  pair<double, int> dist1[n], dist2[n];
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    temp = sqrt((x - tx) * (x - tx) + (y - ty) * (y - ty));
    ans += 2 * temp;
    dist1[i].first = sqrt((x - ax) * (x - ax) + (y - ay) * (y - ay)) - temp;
    dist2[i].first = sqrt((x - bx) * (x - bx) + (y - by) * (y - by)) - temp;
    dist1[i].second = dist2[i].second = i;
  }
  sort(dist1, dist1 + n);
  sort(dist2, dist2 + n);
  if ((dist1[0].first >= 0 && dist1[0].first <= dist2[0].first) ||
      (dist1[0].first < 0 &&
       (dist1[0].second != dist2[0].second || dist2[0].first >= 0 ||
        (n == 1 && dist1[0].first < dist2[0].first) ||
        (n > 1 && dist1[0].first + min(0.0, dist2[1].first) <=
                      dist2[0].first + min(0.0, dist1[1].first))))) {
    ans += dist1[0].first;
    if (dist1[0].second != dist2[0].second && dist2[0].first < 0)
      ans += dist2[0].first;
    else if (n > 1 && dist2[1].first < 0)
      ans += dist2[1].first;
  } else {
    ans += dist2[0].first;
    if (dist1[1].first < 0) ans += dist1[1].first;
  }
  cout << fixed << setprecision(15) << ans;
  return 0;
}
