#include <bits/stdc++.h>
using namespace std;
struct Point {
  double x, y;
  Point(double x, double y) : x(x), y(y) {}
  Point() : x(0), y(0) {}
  void read() { scanf("%lf %lf", &x, &y); }
  void print() { printf("%.9lf %.9lf", x, y); }
  Point &operator=(const Point &o) {
    x = o.x;
    y = o.y;
    return *this;
  }
  Point &operator+=(const Point &o) {
    x += o.x;
    y += o.y;
    return *this;
  }
  Point &operator-=(const Point &o) {
    x -= o.x;
    y -= o.y;
    return *this;
  }
  Point &operator*=(double fact) {
    x -= fact;
    y -= fact;
    return *this;
  }
  Point &operator/=(double fact) {
    x /= fact;
    y /= fact;
    return *this;
  }
};
Point any;
Point operator-(const Point &a) { return Point(-a.x, -a.y); }
Point operator+(const Point &a, const Point &b) {
  return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point &a, const Point &b) {
  return Point(a.x - b.x, a.y - b.y);
}
double operator*(const Point &a, const Point &b) {
  return a.x * b.x + a.y * b.y;
}
double operator^(const Point &a, const Point &b) {
  return a.x * b.y - a.y * b.x;
}
Point operator*(const double factor, const Point &p) {
  return Point(factor * p.x, factor * p.y);
}
Point operator*(const Point &p, const double factor) {
  return Point(factor * p.x, factor * p.y);
}
bool operator==(const Point &a, const Point &b) {
  return a.x == b.x && a.y == b.y;
}
bool operator!=(const Point &a, const Point &b) {
  return a.x != b.x || a.y != b.y;
}
double angle(const Point &p) { return atan2(p.y, p.x); }
double angle(const Point &a, const Point &b) { return atan2(a ^ b, a * b); }
Point rotate(const Point &p, double an) {
  return Point(p.x * sin(an) - p.y * cos(an), p.x * cos(an) + p.y * sin(an));
}
Point rotate(const Point &p, double an, Point &around) {
  return rotate(p - around, an) + around;
}
double abs(const Point &p) { return p * p; }
double norm(const Point &p) { return sqrt(p * p); }
Point perp(const Point &p) { return Point(-p.y, p.x); }
Point bisector(const Point &a, const Point &b) {
  return a * norm(b) + b * norm(a);
}
double proj(const Point &a, const Point &b) { return a * b / norm(b); }
struct Line {
  Point a, ab;
  Line(const Point &a, const Point &b) : a(a), ab(b - a) {}
  Line() : a(), ab() {}
  Point b() { return a + ab; }
};
bool online(const Line &l, Point &p) { return ((p - l.a) ^ l.ab) == 0; }
double dist(const Line &l, Point &p) {
  return abs(((p - l.a) ^ l.ab) / norm(l.ab));
}
bool inter(const Line &s1, const Line &s2, Point &res) {
  if ((s1.ab ^ s2.ab) == 0) return 0;
  double t = ((s2.a - s1.a) ^ s2.ab) / (s1.ab ^ s2.ab);
  res = s1.a + s1.ab * t;
  return 1;
}
double proj(const Point &p, const Line &l, Point &res) {
  res = l.a;
  res += l.ab * (((p - l.a) * l.ab) / abs(l.ab));
}
void reflection(const Point &p, const Line &l, Point &res) {
  proj(p, l, res);
  res = 2 * res - p;
}
struct Segment {
  Point a, ab;
  Segment(const Point &a, const Point &b) : a(a), ab(b - a) {}
  Segment() : a(), ab() {}
  Point b() const { return a + ab; }
};
bool onsegment(const Segment &r, const Point &p) {
  return ((p - r.a) ^ r.ab) == 0 && ((p - r.a) * (p - r.b())) <= 0;
}
double dist(const Segment &r, const Point &p) {
  if ((p - r.a) * (r.ab) <= 0) return norm(p - r.a);
  if ((p - r.b()) * (-r.ab) <= 0) return norm(p - r.b());
  return abs(((p - r.a) ^ r.ab) / norm(r.ab));
}
bool bet(const Segment &s1, const Segment &s2, const Point &p) {
  return (dist(s1, p) + dist(s2, p) == dist(s2, s1.a));
}
bool inter(const Segment &s1, const Segment &s2, Point &res = any) {
  if ((s1.ab ^ s2.ab) == 0) return 0;
  double t1 = ((s2.a - s1.a) ^ s2.ab) / (s1.ab ^ s2.ab);
  double t2 = ((s1.a - s2.a) ^ s1.ab) / (s2.ab ^ s1.ab);
  if (t1 < 0 || t1 > 1 || t2 < 0 || t2 > 1) return 0;
  res = s1.a + s1.ab * t1;
  return 1;
}
vector<pair<pair<double, pair<double, double> >, int> > v;
double solve(int x, Point &a, Point &b, Point &t, double ans) {
  ans -= norm(t - Point(v[x].first.second.first, v[x].first.second.second));
  int prevn = v[x].second;
  pair<double, double> prevp = v[x].first.second;
  if (prevn == 1)
    ans += norm(a - Point(v[x].first.second.first, v[x].first.second.second));
  else
    ans += norm(b - Point(v[x].first.second.first, v[x].first.second.second));
  for (int i = 0; i < (int)v.size(); i++) {
    if (v[i].second != prevn && v[i].first.second != prevp) {
      prevn = v[i].second;
      if (v[i].first.first > 0) {
        ans -=
            norm(t - Point(v[i].first.second.first, v[i].first.second.second));
        if (prevn == 1)
          ans += norm(a -
                      Point(v[i].first.second.first, v[i].first.second.second));
        else
          ans += norm(b -
                      Point(v[i].first.second.first, v[i].first.second.second));
      }
      break;
    }
  }
  return ans;
}
int main() {
  double ax, ay, bx, by, tx, ty, n, x, y, da, db, dt, ans = 0;
  cin >> ax >> ay >> bx >> by >> tx >> ty >> n;
  Point a(ax, ay), b(bx, by), t(tx, ty);
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    Point u(x, y);
    da = norm(a - u);
    db = norm(b - u);
    dt = norm(t - u);
    ans += dt * 2;
    v.push_back({{dt - da, {x, y}}, 1});
    v.push_back({{dt - db, {x, y}}, 2});
  }
  sort(v.begin(), v.end(),
       greater<pair<pair<double, pair<double, double> >, int> >());
  cout << fixed << setprecision(12)
       << min(solve(0, a, b, t, ans), solve(1, a, b, t, ans));
  return 0;
}
