#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 5;
const long long N = 1e6 + 5;
long long Kx, Ky, Cx, Cy, Tx, Ty, n, x, y, i;
double pre[N], suff[N], add[N], all, adds, ans;
double dist(long long x, long long y, long long a, long long b) {
  return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  cin >> Kx >> Ky >> Cx >> Cy >> Tx >> Ty >> n;
  for (i = 1; i <= n; ++i) {
    cin >> x >> y;
    adds = dist(Tx, Ty, x, y);
    all += adds * 2;
    suff[i] = pre[i] = dist(Cx, Cy, x, y) - adds;
    add[i] = dist(Kx, Ky, x, y) - adds;
  }
  pre[0] = suff[n + 1] = inf;
  for (i = 1; i <= n; ++i) pre[i] = min(pre[i - 1], pre[i]);
  for (i = n; i > 0; --i) suff[i] = min(suff[i + 1], suff[i]);
  ans = suff[1] + all;
  for (i = 1; i <= n; ++i)
    ans = min(ans, all + min(0.0, min(pre[i - 1], suff[i + 1])) + add[i]);
  cout << fixed << setprecision(7) << ans;
  return 0;
}
