#include <bits/stdc++.h>
using namespace std;
double dis(pair<double, double> a, pair<double, double> b) {
  return sqrt((a.first - b.first) * (a.first - b.first) +
              (a.second - b.second) * (a.second - b.second));
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cout.precision(10);
  cout.setf(ios::fixed);
  double ax, ay, bx, by, tx, ty;
  cin >> ax >> ay >> bx >> by >> tx >> ty;
  int n;
  cin >> n;
  vector<vector<double> > dp(n + 1, vector<double>(4));
  dp[0][0] = 1e18;
  for (int i = 0; i < int(n); i++) {
    double first, second;
    cin >> first >> second;
    double a = dis(make_pair(ax, ay), make_pair(first, second));
    double b = dis(make_pair(bx, by), make_pair(first, second));
    double d = dis(make_pair(first, second), make_pair(tx, ty));
    for (int j = 0; j < int(4); j++) {
      dp[i + 1][j] = 1e18;
      dp[i + 1][j] = min(dp[i + 1][j], d * 2 + dp[i][j]);
      if (!(j & 1)) {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j | 1] + a + d);
      }
      if (!(j & 2)) {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j | 2] + b + d);
      }
    }
  }
  cout << dp[n][0];
  return 0;
}
