#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int maxn = 1e5 + 7;
pair<double, double> da[maxn], db[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  double ax, ay, bx, by, tx, ty;
  int n;
  double ans = 0;
  cin >> ax >> ay >> bx >> by >> tx >> ty;
  cin >> n;
  for (int i = 0; i < n; i++) {
    double x, y;
    cin >> x >> y;
    double dia = 0, dib = 0, dit = 0;
    dia = sqrt((x - ax) * (x - ax) + (y - ay) * (y - ay));
    dib = sqrt((x - bx) * (x - bx) + (y - by) * (y - by));
    dit = sqrt((x - tx) * (x - tx) + (y - ty) * (y - ty));
    ans += dit * 2.0;
    da[i].first = dit - dia;
    db[i].first = dit - dib;
    da[i].second = i;
    db[i].second = i;
  }
  sort(da, da + n);
  sort(db, db + n);
  double ans1 = 0, ans2 = 0;
  if (n == 1)
    cout << setprecision(10)
         << min(ans - da[n - 1].first, ans - db[n - 1].first) << endl;
  else {
    ans1 = (ans - max(da[n - 1].first, db[n - 1].first)) * 1.0;
    if (da[n - 1].second != db[n - 1].second)
      ans2 = ans - (da[n - 1].first + db[n - 1].first);
    else
      ans2 = ans - max(da[n - 1].first + db[n - 2].first,
                       da[n - 2].first + db[n - 1].first);
    ans = min(ans1, ans2);
    cout << setprecision(10) << ans << endl;
  }
  return 0;
}
