#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
double dist(int x1, int y1, int x2, int y2) {
int a = x1 - x2, b = y1 - y2;
return sqrt( (x1-x2)*(x1-x2) + (y1-y2) * (y1-y2));
}
int main() {
pair<int,int> adil, ber, bin;
double total = 0;
cin >> adil.f >> adil.s;
cin >> ber.f >> ber.s;
cin >> bin.f >> bin.s;
int n;
cin >> n;
vector<pair<int,int> > rub(n);
for (int i = 0; i < n; i++) {
cin >> rub[i].f >> rub[i].s;
total += 2 * dist(rub[i].f, rub[i].s,bin.f, bin.s);
}
vector<double> a(n), b(n);
double ans = 1e15, p1 = 1e15, p2 = 1e15;
for (int i = 0; i < n; i++) {
a[i] = dist(adil.f, adil.s, rub[i].f, rub[i].s) - dist(rub[i].f, rub[i].s, bin.f, bin.s);
b[i] = dist(ber.f, ber.s, rub[i].f, rub[i].s) - dist(rub[i].f, rub[i].s, bin.f, bin.s);
ans = min(ans, a[i]);
ans = min(ans, b[i]);
ans = min(ans, a[i] + p2);
ans = min(ans, b[i] + p1);
p1 = min(p1, a[i]);
p2 = min(p2, b[i]);
}
ans += total;
cout << fixed << double(ans);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBmIGZpcnN0CiNkZWZpbmUgcyBzZWNvbmQKCmRvdWJsZSBkaXN0KGludCB4MSwgaW50IHkxLCBpbnQgeDIsIGludCB5MikgewogICAgaW50IGEgPSB4MSAtIHgyLCBiID0geTEgLSB5MjsKICAgIHJldHVybiBzcXJ0KCAoeDEteDIpKih4MS14MikgKyAoeTEteTIpICogKHkxLXkyKSk7Cn0KCmludCBtYWluKCkgewogICAgcGFpcjxpbnQsaW50PiBhZGlsLCBiZXIsIGJpbjsKICAgIGRvdWJsZSB0b3RhbCA9IDA7CgogICAgY2luID4+IGFkaWwuZiA+PiBhZGlsLnM7CiAgICBjaW4gPj4gYmVyLmYgPj4gYmVyLnM7CiAgICBjaW4gPj4gYmluLmYgPj4gYmluLnM7CgogICAgaW50IG47CgogICAgY2luID4+IG47CgogICAgdmVjdG9yPHBhaXI8aW50LGludD4gPiBydWIobik7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBjaW4gPj4gcnViW2ldLmYgPj4gcnViW2ldLnM7CiAgICAgICAgdG90YWwgKz0gMiAqIGRpc3QocnViW2ldLmYsIHJ1YltpXS5zLGJpbi5mLCBiaW4ucyk7CgogICAgfQoKICAgIHZlY3Rvcjxkb3VibGU+IGEobiksIGIobik7CgogICAgZG91YmxlIGFucyA9IDFlMTUsIHAxID0gMWUxNSwgcDIgPSAxZTE1OwoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgYVtpXSA9IGRpc3QoYWRpbC5mLCBhZGlsLnMsIHJ1YltpXS5mLCBydWJbaV0ucykgLSBkaXN0KHJ1YltpXS5mLCBydWJbaV0ucywgYmluLmYsIGJpbi5zKTsKICAgICAgICBiW2ldID0gZGlzdChiZXIuZiwgYmVyLnMsIHJ1YltpXS5mLCBydWJbaV0ucykgLSBkaXN0KHJ1YltpXS5mLCBydWJbaV0ucywgYmluLmYsIGJpbi5zKTsKCiAgICAgICAgYW5zID0gbWluKGFucywgYVtpXSk7CiAgICAgICAgYW5zID0gbWluKGFucywgYltpXSk7CgogICAgICAgIGFucyA9IG1pbihhbnMsIGFbaV0gKyBwMik7CiAgICAgICAgYW5zID0gbWluKGFucywgYltpXSArIHAxKTsKCiAgICAgICAgcDEgPSBtaW4ocDEsIGFbaV0pOwogICAgICAgIHAyID0gbWluKHAyLCBiW2ldKTsKCiAgICB9CgogICAgYW5zICs9IHRvdGFsOwoKICAgIGNvdXQgPDwgZml4ZWQgPDwgZG91YmxlKGFucyk7CgoKICAgIHJldHVybiAwOwp9