#include <bits/stdc++.h>
using namespace std;
long double ax, ay, bx, by, cx, cy, z;
int n;
pair<long double, long double> p[200001];
int main() {
  cin >> ax >> ay >> bx >> by >> cx >> cy >> n;
  for (int i = 1; i <= n; i++) {
    long double x, y;
    cin >> x >> y;
    long double dis = hypot(cx - x, cy - y);
    z += dis * 2;
    p[i].first = dis - hypot(ax - x, ay - y);
    p[i].second = dis - hypot(bx - x, by - y);
  }
  sort(p + 1, p + n + 1);
  long double tmp = -1e9;
  tmp = max(p[n - 1].first + p[n].second, max(p[n].first, p[n].second));
  for (int i = n - 1; i > 0; i--)
    tmp = max(tmp, max(p[n].first + p[i].second, max(p[i].first, p[i].second)));
  cout << fixed << setprecision(9) << z - tmp;
  return 0;
}
