#include <bits/stdc++.h>
using namespace std;
long long x[200007], y[200007], ax, ay, bx, by, tx, ty, n, mark[200007], cnt,
    mark2[200007];
long double ans;
set<pair<long double, long long> > st[2];
long double calc(long long a, long long b, long long c, long long d) {
  return sqrtl((a - c) * (a - c) + (b - d) * (b - d));
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> ax >> ay >> bx >> by >> tx >> ty >> n;
  for (long long i = 1; i <= n; ++i)
    cin >> x[i] >> y[i], ans += 2 * calc(tx, ty, x[i], y[i]);
  for (long long i = 1; i <= n; ++i) {
    st[0].insert(
        make_pair(calc(ax, ay, x[i], y[i]) - calc(tx, ty, x[i], y[i]), i));
    st[1].insert(
        make_pair(calc(bx, by, x[i], y[i]) - calc(tx, ty, x[i], y[i]), i));
  }
  st[0].insert(make_pair(1.0 * 10000000000007ll, 10000000000007ll));
  st[1].insert(make_pair(1.0 * 10000000000007ll, 10000000000007ll));
  auto a1 = *st[0].begin(), a2 = *(++st[0].begin()), b1 = *st[1].begin(),
       b2 = *(++st[1].begin());
  if (a1.first >= 0 && b1.first >= 0) ans += min(a1.first, b1.first);
  if (a1.first <= 0 && b1.first <= 0) {
    if (b1.second == a1.second) {
      long double cur = min(a1.first + b2.first, b1.first + a2.first);
      if (b2.first > 0) cur = min(cur, a1.first);
      if (a2.first > 0) cur = min(cur, b1.first);
      ans += cur;
    } else
      ans += b1.first + a1.first;
  } else if ((a1.first <= 0) ^ (b1.first <= 0) == 1)
    ans += min(a1.first, b1.first);
  cout << fixed << setprecision(8) << ans << endl;
  return 0;
}
