#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
int n, ax, ay, bx, by, tx, ty, x[MAX], y[MAX];
long double memo[MAX][2][2][2][2];
bool vis[MAX][2][2][2][2];
inline long double getDist(int p1x, int p1y, int p2x, int p2y) {
  return sqrt(1.0 * (p1x - p2x) * (p1x - p2x) +
              1.0 * (p1y - p2y) * (p1y - p2y));
}
double dp(int i, bool flag1, bool flag2, bool take1, bool take2) {
  if (i == n) {
    if ((take1 && !flag1) || (take2 && !flag2)) return 1e18;
    return 0;
  }
  if (vis[i][flag1][flag2][take1][take2])
    return memo[i][flag1][flag2][take1][take2];
  vis[i][flag1][flag2][take1][take2] = 1;
  long double& ret = memo[i][flag1][flag2][take1][take2];
  long double cost1 = (2.0 * getDist(tx, ty, x[i], y[i]));
  ret = cost1 + min(dp(i + 1, flag1, flag2, 1, take2),
                    dp(i + 1, flag1, flag2, take1, 1));
  if (!flag1) {
    long double cost2 =
        getDist(ax, ay, x[i], y[i]) + getDist(tx, ty, x[i], y[i]);
    ret = min(ret, cost2 + dp(i + 1, 1, flag2, 1, take2));
  }
  if (!flag2) {
    long double cost3 =
        getDist(bx, by, x[i], y[i]) + getDist(tx, ty, x[i], y[i]);
    ret = min(ret, cost3 + dp(i + 1, flag1, 1, take1, 1));
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> ax >> ay >> bx >> by >> tx >> ty >> n;
  for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];
  cout << setprecision(7) << dp(0, 0, 0, 0, 0);
  return 0;
}
