#include <bits/stdc++.h>
long double distance(const std::pair<long double, long double>& p1,
                     const std::pair<long double, long double>& p2) {
  return std::hypot(p1.first - p2.first, p1.second - p2.second);
}
int main() {
  long double ax, ay, bx, by, tx, ty;
  std::cin >> ax >> ay >> bx >> by >> tx >> ty;
  auto a = std::make_pair(ax, ay);
  auto b = std::make_pair(bx, by);
  auto t = std::make_pair(tx, ty);
  std::size_t n;
  std::cin >> n;
  std::vector<std::pair<long double, long double>> bottles(n);
  long double total_length = 0;
  for (std::size_t i = 0; i < n; ++i) {
    std::cin >> bottles.at(i).first >> bottles.at(i).second;
    total_length += 2 * distance(t, bottles.at(i));
  }
  long double a_answer = total_length;
  long double b_answer = total_length;
  int a_first = -1;
  int b_first = -1;
  for (std::size_t i = 0; i < n; ++i) {
    if (a_answer > total_length - distance(t, bottles.at(i)) +
                       distance(a, bottles.at(i))) {
      a_answer = total_length - distance(t, bottles.at(i)) +
                 distance(a, bottles.at(i));
      a_first = i;
    }
    if (b_answer > total_length - distance(t, bottles.at(i)) +
                       distance(b, bottles.at(i))) {
      b_answer = total_length - distance(t, bottles.at(i)) +
                 distance(b, bottles.at(i));
      b_first = i;
    }
  }
  if (a_first == -1 && b_first == -1) {
    auto a_min = std::min_element(
        std::begin(bottles), std::end(bottles),
        [&a, &t](const std::pair<long double, long double>& b1,
                 const std::pair<long double, long double>& b2) {
          return -distance(t, b1) + distance(a, b1) <
                 -distance(t, b2) + distance(a, b2);
        });
    auto b_min = std::min_element(
        std::begin(bottles), std::end(bottles),
        [&b, &t](const std::pair<long double, long double>& b1,
                 const std::pair<long double, long double>& b2) {
          return -distance(t, b1) + distance(b, b1) <
                 -distance(t, b2) + distance(b, b2);
        });
    a_answer = total_length - distance(t, *a_min) + distance(a, *a_min);
    b_answer = total_length - distance(t, *b_min) + distance(b, *b_min);
    std::cout << std::fixed << std::setprecision(20)
              << std::min(a_answer, b_answer) << std::endl;
  } else if (a_first == -1) {
    std::cout << std::fixed << std::setprecision(20) << b_answer << std::endl;
  } else if (b_first == -1) {
    std::cout << std::fixed << std::setprecision(20) << a_answer << std::endl;
  } else if (a_first != b_first) {
    long double answer = total_length;
    answer = answer - distance(t, bottles.at(a_first)) +
             distance(a, bottles.at(a_first));
    answer = answer - distance(t, bottles.at(b_first)) +
             distance(b, bottles.at(b_first));
    std::cout << std::fixed << std::setprecision(20) << answer << std::endl;
  } else {
    auto aa_answer = a_answer;
    auto bb_answer = b_answer;
    for (std::size_t i = 0; i < n; ++i) {
      if (i == b_first) {
        continue;
      }
      if (b_answer >
          bb_answer - distance(t, bottles.at(i)) + distance(a, bottles.at(i))) {
        b_answer =
            bb_answer - distance(t, bottles.at(i)) + distance(a, bottles.at(i));
      }
      if (a_answer >
          aa_answer - distance(t, bottles.at(i)) + distance(b, bottles.at(i))) {
        a_answer =
            aa_answer - distance(t, bottles.at(i)) + distance(b, bottles.at(i));
      }
    }
    std::cout << std::fixed << std::setprecision(20)
              << std::min(a_answer, b_answer) << std::endl;
  }
  return 0;
}
