#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <set>
#include <fstream>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <iterator>
using namespace std;
#define sqr(x) ((x)*(x))
#define cbr(x) ((x)*(x)*(x))
#define max(a, b) (((a)<(b))? (b):(a))
#define min(a, b) (((a)<(b))? (a):(b))
#define all(a) a.begin(), a.end()
#define _sp system("pause");
#define _ln cout << "------------------------------------------------\n";
#define FI(a, n) for(int i=a;i<n;i++)
#define FJ(a, n) for(int j=a;j<n;j++)
#define REP(a, b, c) for(int (c) = (a); (c) < (b); (c)++)
#define rep(a, b, c) for(int (c) = (a); (c) < (b); (c)++)
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define x1 sasimathx1
#define y1 sasimathy1
void delbit(ll &a, ll k) { a &= (~(1 << k)); }
bool getbit(ll a, ll k) { return 1 & (a >> k); }
ll setbit(ll &a, ll k) { return a |= (1 << k); }
inline ll mulmod(ll x, ll n, ll _mod) { ll res = 0; while (n) { if (n & 1)res = (res + x) % _mod; x = (x + x) % _mod; n >>= 1; }return res; }
inline ll powmod(ll x, ll n, ll _mod) { ll res = 1; while (n) { if (n & 1)res = (res*x) % _mod; x = (x*x) % _mod; n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { ll t; while (b) { a = a%b; t = a; a = b; b = t; }return a; }
inline int gcd(int a, int b) { int t; while (b) { a = a%b; t = a; a = b; b = t; }return a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
inline ll gcd(ll a, ll b, ll c) { return gcd(gcd(a, b), c); }
inline int gcd(int a, int b, int c) { return gcd(gcd(a, b), c); }
double dist(double ax, double ay, double bx, double by) { return sqrt(sqr(ax - bx) + sqr(ay - by)); }
//constants
#define PI 3.1415926535897932
#define INF 2147483640
#define LLINF 9223372036854775806
#define eps 1e-14
//-------------------------------------------------
#define N 100010
pair<double, int> p[N];
double da[N];
int n;
double go(int j) {
rep(0, n, i) {
if (p[i].second != j)return p[i].first;
}
return LLINF;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
double Ax, Bx, Tx, Ay, By, Ty, sum = 0;
cin >> Ax >> Ay >> Bx >> By >> Tx >> Ty;
cin >> n;
rep(0, n, i) {
double x, y;
cin >> x >> y;
double add = dist(Tx, Ty, x, y);
sum += add * 2;
p[i].first = dist(Bx, By, x, y) - add;
p[i].second = i;
da[i] = dist(Ax, Ay, x, y) - add;
}
sort(p, p + n);
double ans = LLINF;
rep(0, n, i) {
ans = min(ans, sum + da[i] + min(0, go(i)));
}
ans = min(ans, sum + go(-1));
printf("%.12lf\n", ans);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8Y3N0ZGxpYj4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8ZnN0cmVhbT4KI2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPGl0ZXJhdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBzcXIoeCkgKCh4KSooeCkpCiNkZWZpbmUgY2JyKHgpICgoeCkqKHgpKih4KSkKI2RlZmluZSBtYXgoYSwgYikgKCgoYSk8KGIpKT8gKGIpOihhKSkKI2RlZmluZSBtaW4oYSwgYikgKCgoYSk8KGIpKT8gKGEpOihiKSkKI2RlZmluZSBhbGwoYSkgYS5iZWdpbigpLCBhLmVuZCgpCgojZGVmaW5lIF9zcCBzeXN0ZW0oInBhdXNlIik7CiNkZWZpbmUgX2xuIGNvdXQgPDwgIi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tL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