#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<queue>
#include<math.h>
#include<algorithm>
using namespace std;
#define db double
#define inf 1e19
const int N=1e6+5;
db ax,ay,bx,by,tx,ty;
db dis(db x0,db y0,db x1,db y1)
{
    return  sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));
}
db a[N],b[N],c[N];
int main()
{
    int n;
    db px,py;
    while(scanf("%lf%lf",&ax,&ay)!=EOF)
    {
        scanf("%lf%lf%lf%lf",&bx,&by,&tx,&ty);
        scanf("%d",&n);
        db sum=0,ans=0;
        for(int i=1; i<=n ;i++)
        {
            scanf("%lf%lf",&px,&py);
            db v = dis(px,py,tx,ty);
            a[i]=dis(bx,by,px,py)-v;
            b[i]=dis(ax,ay,px,py)-v;
            c[i]=a[i];
            ans += 2*v;
        }

        a[0]=inf;
        c[n+1]=inf;
        for(int i=1; i<=n ;i++)
            a[i]=min(a[i],a[i-1]);
        for(int i=n; i>=1 ;i--)
        {
            c[i]=min(c[i+1],c[i]);
        }
        sum=c[1]+ans;
        for(int i=1; i<=n ;i++)
            sum=min(sum,ans+b[i]+min(0.0,min(a[i-1],c[i+1])));
        printf("%lf\n",sum);
    }
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<queue>
#include<math.h>
#include<algorithm>
using namespace std;
const int N=1e5+5;
struct point
{
    double z;
    int pos;
}a[N],b[N];;
//p[N],q[N]
double ax,ay,bx,by,tx,ty;
double dis(double x0,double y0,double x1,double y1)
{
    return  sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));
}
double abs(double x)
{
    return x>=0?x:-x;
}
double cmp(point aa,point bb)
{
    return aa.z<bb.z;
}
int main()
{
    int n;
    double px,py;
    while(scanf("%lf%lf",&ax,&ay)!=EOF)
    {
        scanf("%lf%lf%lf%lf",&bx,&by,&tx,&ty);
        scanf("%d",&n);
        double sum=0;
        for(int i=0; i<n ;i++)
        {
            scanf("%lf%lf",&px,&py);
            a[i].z=dis(ax,ay,px,py)-dis(px,py,tx,ty);
            b[i].z=dis(bx,by,px,py)-dis(px,py,tx,ty);
            a[i].pos=i;
            b[i].pos=i;
            sum += 2*dis(px,py,tx,ty);
        }
        sort(a,a+n,cmp);
        sort(b,b+n,cmp);
        if(a[0].pos!=b[0].pos)
        {
            sum=sum+a[0].z+b[0].z;
        }
        else
        {
            sum+=min((min(a[0].z,0.0)+min(b[1].z,0.0)),(min(b[0].z,0.0)+min(a[1].z,0.0)));
        }
        printf("%lf\n",sum);
    }
    return 0;
}
/*
1 0 0 1 0 0
1
1 1
*/


#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e10;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N + 1], db[MAX_N + 1];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> p[i].x >> p[i].y;
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	da[N] = make_pair(0, -1);
	db[N] = make_pair(0, -1);
	sort(da, da + N); reverse(da, da + N);
	sort(db, db + N); reverse(db, db + N);
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		if (N == 1)
		{
			ans = sum*2 - max(da[0].first, db[0].first);
		}
		else
		{
			for (int i = 0; i < 2; i++)
			{
				ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
			}
		}
		printf("%f\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e10;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N + 1], db[MAX_N + 1];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		scanf("%lf%lf", &p[i].x, &p[i].y);
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	da[N] = make_pair(0, -1);
	db[N] = make_pair(0, -1);
	sort(da, da + N + 1); reverse(da, da + N + 1);
	sort(db, db + N + 1); reverse(db, db + N + 1);
	double ans = DINF;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			if (da[i].second == db[j].second) continue;
			ans = min(ans, sum*2 - da[i].first - db[j].first);
		}
	}
	printf("%f\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e10;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N], db[MAX_N];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> p[i].x >> p[i].y;
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	sort(da, da + N); reverse(da, da + N);
	sort(db, db + N); reverse(db, db + N);
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		if (N == 1)
		{
			ans = sum*2 - max(da[0].first, db[0].first);
		}
		else
		{
			for (int i = 0; i < 2; i++)
			{
				ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
			}
		}
		printf("%f\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e19;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N + 1], db[MAX_N + 1];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		scanf("%lf%lf", &p[i].x, &p[i].y);
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	da[N] = make_pair(0, -1);
	db[N] = make_pair(0, -1);
	sort(da, da + N + 1); reverse(da, da + N + 1);
	sort(db, db + N + 1); reverse(db, db + N + 1);
	if (N == 1) abort();
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		if (N == 1)
		{
			ans = sum*2 - max(da[0].first, db[0].first);
		}
		else
		{
			for (int i = 0; i < 2; i++)
			{
				ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
			}
		}
		printf("%f\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e10;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N + 1], db[MAX_N + 1];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> p[i].x >> p[i].y;
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	da[N] = make_pair(0, -1);
	db[N] = make_pair(0, -1);
	sort(da, da + N + 1); reverse(da, da + N + 1);
	sort(db, db + N + 1); reverse(db, db + N + 1);
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		if (N == 1)
		{
			ans = sum*2 - max(da[0].first, db[0].first);
		}
		else
		{
			for (int i = 0; i < 2; i++)
			{
				ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
			}
		}
		printf("%f\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e19;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N + 1], db[MAX_N + 1];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		scanf("%lf%lf", &p[i].x, &p[i].y);
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	da[N] = make_pair(0, -1);
	db[N] = make_pair(0, -1);
	sort(da, da + N + 1); reverse(da, da + N + 1);
	sort(db, db + N + 1); reverse(db, db + N + 1);
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		if (N == 1)
		{
			ans = sum*2 - max(da[0].first, db[0].first);
		}
		else
		{
			for (int i = 0; i < 2; i++)
			{
				ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
			}
		}
		printf("%f\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e10;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N], db[MAX_N];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> p[i].x >> p[i].y;
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	sort(da, da + N); reverse(da, da + N);
	sort(db, db + N); reverse(db, db + N);
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		for (int i = 0; i < 2; i++)
		{
			ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
		}
		printf("%f\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e10;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N + 1], db[MAX_N + 1];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		scanf_s("%lf%lf", &p[i].x, &p[i].y);
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	da[N] = make_pair(0, -1);
	db[N] = make_pair(0, -1);
	sort(da, da + N + 1); reverse(da, da + N + 1);
	sort(db, db + N + 1); reverse(db, db + N + 1);
	double ans = DINF;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			if (da[i].second == db[j].second) continue;
			ans = min(ans, sum*2 - da[i].first - db[j].first);
		}
	}
	printf("%f\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e10;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N + 1], db[MAX_N + 1];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		scanf("%lf%lf", &p[i].x, &p[i].y);
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	da[N] = make_pair(0, -1);
	db[N] = make_pair(0, -1);
	sort(da, da + N + 1); reverse(da, da + N + 1);
	sort(db, db + N + 1); reverse(db, db + N + 1);
	if (N == 1) abort();
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		if (N == 1)
		{
			ans = sum*2 - max(da[0].first, db[0].first);
		}
		else
		{
			for (int i = 0; i < 2; i++)
			{
				ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
			}
		}
		printf("%f\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e10;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N + 1], db[MAX_N + 1];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		scanf("%lf%lf", &p[i].x, &p[i].y);
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	da[N] = make_pair(0, -1);
	db[N] = make_pair(0, -1);
	sort(da, da + N + 1); reverse(da, da + N + 1);
	sort(db, db + N + 1); reverse(db, db + N + 1);
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		if (N == 1)
		{
			abort();
			ans = sum*2 - max(da[0].first, db[0].first);
		}
		else
		{
			for (int i = 0; i < 2; i++)
			{
				ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
			}
		}
		printf("%f\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e10;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N], db[MAX_N];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> p[i].x >> p[i].y;
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	sort(da, da + N); reverse(da, da + N);
	sort(db, db + N); reverse(db, db + N);
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		if (N == 1)
		{
			ans = sum*2 - max(da[0].first - b.GetDist(t), db[0].first - a.GetDist(t));
		}
		else
		{
			for (int i = 0; i < 2; i++)
			{
				ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
			}
		}
		printf("%f\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e19;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N + 1], db[MAX_N + 1];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		scanf("%lf%lf", &p[i].x, &p[i].y);
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	da[N] = make_pair(0, -1);
	db[N] = make_pair(0, -1);
	sort(da, da + N + 1); reverse(da, da + N + 1);
	sort(db, db + N + 1); reverse(db, db + N + 1);
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		if (true)
		{
			for (int i = 0; i < 2; i++)
			{
				ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
			}
		}
		printf("%f\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e10;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N], db[MAX_N];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> p[i].x >> p[i].y;
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	sort(da, da + N); reverse(da, da + N);
	sort(db, db + N); reverse(db, db + N);
	if (da[0].second != db[0].second)
	{
		printf("%f\n", sum*2 - da[0].first - db[0].first);
	}
	else
	{
		double ans = DINF;
		if (N == 1)
		{
			abort();
			ans = sum*2 - max(da[0].first - b.GetDist(t), db[0].first - a.GetDist(t));
		}
		else
		{
			for (int i = 0; i < 2; i++)
			{
				ans = min(ans, sum*2 - da[i].first - db[1 - i].first);
			}
		}
		printf("%f\n", ans);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_N = 100000;
const double DINF = 1e19;

struct Point
{
	double x, y;
	Point() {}
	Point(double _x, double _y)
	{
		x = _x; y = _y;
	}
	double abs() const
	{
		return sqrt(x*x + y*y);
	}
	double GetDist(const Point &p) const
	{
		return Point(x - p.x, y - p.y).abs();
	}
};

Point a, b, t, p[MAX_N];
int N;
pair<double, int> da[MAX_N + 1], db[MAX_N + 1];

signed main()
{
	cin >> a.x >> a.y >> b.x >> b.y >> t.x >> t.y >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		scanf("%lf%lf", &p[i].x, &p[i].y);
		sum += t.GetDist(p[i]);
		da[i] = make_pair(t.GetDist(p[i]) - a.GetDist(p[i]), i);
		db[i] = make_pair(t.GetDist(p[i]) - b.GetDist(p[i]), i);
	}
	da[N] = make_pair(0, -1);
	db[N] = make_pair(0, -1);
	sort(da, da + N + 1); reverse(da, da + N + 1);
	sort(db, db + N + 1); reverse(db, db + N + 1);
	double ans = DINF;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			if (da[i].second == db[j].second) continue;
			ans = min(ans, sum*2 - da[i].first - db[j].first);
		}
	}
	printf("%f\n", ans);
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second

using namespace std;

double dist(pair< long int, long int> a, pair<long int, long int> b)
{
    return sqrt((double)((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s)));
}

int main()
{
    pair<long int, long int> a, b, t;

    cin >> a.f >> a.s >> b.f >> b.s >> t.f >> t.s;

    int n;

    cin >> n;

    vector<pair<long int, long int> > v(n,mp(0,0));
    vector<double> d(n,0.0);
    vector<double> vA(n,0.0);
    vector<double> vB(n,0.0);
    double totalDist = 0.0;
    double minA1 = DBL_MAX,minA2 = DBL_MAX, minB1 = DBL_MAX, minB2 = DBL_MAX;
    int ia, ib;

    for(int i = 0; i < n; i++)
    {
        cin >> v[i].f >> v[i].s;

 		d[i] = dist(t,v[i]);
 		vA[i] = dist(a,v[i]) - d[i];

 		if(vA[i] < minA1)
 		{
 			minA2 = min(minA2,minA1);
 			minA1 = vA[i];
 			ia = i;
 		}
 		else
 			minA2 = min(minA2,vA[i]);

 		vB[i] = dist(b,v[i]) - d[i];

 		if(vB[i] < minB1)
 		{
 			minB2 = min(minB2,minB1);
 			minB1 = vB[i];
 			ib = i;
 		}
 		else
 			minB2 = min(minB2,vB[i]);

        totalDist += 2.0*d[i];
    }

    double resp = DBL_MAX;

    resp = min(resp,totalDist+minA1);
    resp = min(resp,totalDist+minB1);

    for (unsigned int i = 0; i < n; i += 1)
    {
    	if(i != ia)
    		resp = min(resp,(totalDist+minA1)+vB[i]);
    	if(i != ib)
    		resp = min(resp,(totalDist+minB1)+vA[i]);
    }

    printf("%.15lf\n",resp);

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second

using namespace std;

double dist(pair< long int, long int> a, pair<long int, long int> b)
{
    return sqrt((double)((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s)));
}

int main()
{
    pair<long int, long int> a, b, t;

    cin >> a.f >> a.s >> b.f >> b.s >> t.f >> t.s;

    int n;

    cin >> n;

    vector<pair<long int, long int> > v(n,mp(0,0));
    vector<double> d(n,0.0);
    vector<double> vA(n,0.0);
    vector<double> vB(n,0.0);
    double totalDist = 0.0;
    double minA1 = DBL_MAX,minA2 = DBL_MAX, minB1 = DBL_MAX, minB2 = DBL_MAX;
    int ia, ib;

    for(int i = 0; i < n; i++)
    {
        cin >> v[i].f >> v[i].s;

 		d[i] = dist(t,v[i]);
 		vA[i] = dist(a,v[i]) - d[i];

 		if(vA[i] < minA1)
 		{
 			minA2 = min(minA2,minA1);
 			minA1 = vA[i];
 			ia = i;
 		}
 		else
 			minA2 = min(minA2,vA[i]);

 		vB[i] = dist(b,v[i]) - d[i];

 		if(vB[i] < minB1)
 		{
 			minB2 = min(minB2,minB1);
 			minB1 = vB[i];
 			ib = i;
 		}
 		else
 			minB2 = min(minB2,vB[i]);

        totalDist += 2.0*d[i];
    }

    double resp = DBL_MAX;

    resp = min(resp,totalDist+minA1);
    resp = min(resp,totalDist+minB1);

    for (unsigned int i = 0; i < n; i += 1)
    {
    	if(i != ia)
    		resp = min(resp,(totalDist+minA1)+vB[i]);
    	if(i != ib)
    		resp = min(resp,(totalDist+minB1)+vA[i]);
    }

    cout << fixed << setprecision(12) << resp << endl;

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second

using namespace std;

double dist(pair< long int, long int> a, pair<long int, long int> b)
{
    return sqrt((double)((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s)));
}

int main()
{
    pair<long int, long int> a, b, t;

    cin >> a.f >> a.s >> b.f >> b.s >> t.f >> t.s;

    int n;

    cin >> n;

    vector<pair<long int, long int> > v(n+1,mp(0,0));
    vector<double> d(n+1,0.0);
    vector<double> vA(n+1,0.0);
    vector<double> vB(n+1,0.0);
    double totalDist = 0.0;
    double minA1 = DBL_MAX,minA2 = DBL_MAX, minB1 = DBL_MAX, minB2 = DBL_MAX;
    int ia, ib;

    for(unsigned int i = 0; i < n; i++)
    {
        cin >> v[i].f >> v[i].s;

 		d[i] = dist(t,v[i]);

 		vA[i] = dist(a,v[i]) - d[i];
 		vB[i] = dist(b,v[i]) - d[i];

        totalDist += 2.0*d[i];
    }

    for (unsigned int i = 0; i < n; i += 1)
    {

 		if(vA[i] < minA1)
 		{
 			minA1 = min(minA1,vA[i]);
 			ia = i;
 		}

 		if(vB[i] < minB1)
 		{
 			minB1 = min(minB1,vB[i]);
 			ib = i;
 		}
    }

    double resp = HUGE_VAL;

    resp = min(resp,totalDist+minA1);
    resp = min(resp,totalDist+minB1);

    for (unsigned int i = 0; i < n; i += 1)
    {
    	if(i != ia)
    		resp = min(resp,(totalDist+minA1)+vB[i]);
    	if(i != ib)
    		resp = min(resp,(totalDist+minB1)+vA[i]);
    }

    printf("%.12lf\n",resp);

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second

using namespace std;

double dist(pair< long int, long int> a, pair<long int, long int> b)
{
    return sqrt((double)((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s)));
}

int main()
{
    pair<long int, long int> a, b, t;

    cin >> a.f >> a.s >> b.f >> b.s >> t.f >> t.s;

    int n;

    cin >> n;

    vector<pair<long int, long int> > v(n,mp(0,0));
    vector<double> d(n,0.0);
    vector<double> vA(n,0.0);
    vector<double> vB(n,0.0);
    double totalDist = 0.0;
    double minA1 = DBL_MAX,minA2 = DBL_MAX, minB1 = DBL_MAX, minB2 = DBL_MAX;
    int ia, ib;

    for(int i = 0; i < n; i++)
    {
        cin >> v[i].f >> v[i].s;

 		d[i] = dist(t,v[i]);
 		vA[i] = dist(a,v[i]) - d[i];

 		if(vA[i] < minA1)
 		{
 			minA2 = min(minA2,minA1);
 			minA1 = vA[i];
 		}
 		else
 			minA2 = min(minA2,vA[i]);

 		vB[i] = dist(b,v[i]) - d[i];

 		if(vB[i] < minB1)
 		{
 			minB2 = min(minB2,minB1);
 			minB1 = vB[i];
 		}
 		else
 			minB2 = min(minB2,vB[i]);

        totalDist += 2.0*d[i];
    }

    double resp = DBL_MAX;

    resp = min(resp,totalDist+minA1);
    resp = min(resp,totalDist+minB1);
    resp = min(resp,totalDist+minA1+minB2);
    resp = min(resp,totalDist+minB1+minA2);

    cout << fixed << setprecision(12) << resp << endl;

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second

using namespace std;

double dist(pair< long int, long int> a, pair<long int, long int> b)
{
    return sqrt((double)((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s)));
}

int main()
{
    pair<long int, long int> a, b, t;

    cin >> a.f >> a.s >> b.f >> b.s >> t.f >> t.s;

    int n;

    cin >> n;

    vector<pair<long int, long int> > v(n+1,mp(0,0));
    vector<double> d(n+1,0.0);
    vector<double> vA(n+1,0.0);
    vector<double> vB(n+1,0.0);
    double totalDist = 0.0;
    double minA1 = DBL_MAX,minA2 = DBL_MAX, minB1 = DBL_MAX, minB2 = DBL_MAX;
    int ia, ib;

    for(int i = 0; i < n; i++)
    {
        cin >> v[i].f >> v[i].s;

 		d[i] = dist(t,v[i]);
 		vA[i] = dist(a,v[i]) - d[i];

 		if(vA[i] < minA1)
 		{
 			minA1 = min(minA1,vA[i]);
 			ia = i;
 		}

 		vB[i] = dist(b,v[i]) - d[i];

 		if(vB[i] < minB1)
 		{
 			minB1 = min(minB1,vB[i]);
 			ib = i;
 		}

        totalDist += 2.0*d[i];
    }

    double resp = DBL_MAX;

    resp = min(resp,totalDist+minA1);
    resp = min(resp,totalDist+minB1);

    for (unsigned int i = 0; i < n; i += 1)
    {
    	if(i != ia)
    		resp = min(resp,(totalDist+minA1)+vB[i]);
    	if(i != ib)
    		resp = min(resp,(totalDist+minB1)+vA[i]);
    }

    printf("%.15lf\n",resp);

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second

using namespace std;

double dist(pair< long int, long int> a, pair<long int, long int> b)
{
    return sqrt((double)((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s)));
}

int main()
{
    pair<long int, long int> a, b, t;

    cin >> a.f >> a.s >> b.f >> b.s >> t.f >> t.s;

    int n;

    cin >> n;

    vector<pair<long int, long int> > v(n+1,mp(0,0));
    vector<double> d(n+1,0.0);
    vector<double> vA(n+1,0.0);
    vector<double> vB(n+1,0.0);
    double totalDist = 0.0;
    double minA1 = DBL_MAX,minA2 = DBL_MAX, minB1 = DBL_MAX, minB2 = DBL_MAX;
    unsigned int ia, ib;

    for(unsigned int i = 0; i < n; i++)
    {
        cin >> v[i].f >> v[i].s;

 		d[i] = dist(t,v[i]);

 		vA[i] = dist(a,v[i]) - d[i];
 		vB[i] = dist(b,v[i]) - d[i];

        totalDist += 2.0*d[i];
    }

    for (unsigned int i = 0; i < n; i += 1)
    {

 		if(vA[i] < minA1)
 		{
 			minA1 = min(minA1,vA[i]);
 			ia = i;
 		}

 		if(vB[i] < minB1)
 		{
 			minB1 = min(minB1,vB[i]);
 			ib = i;
 		}
    }

    double resp = HUGE_VAL;

    resp = min(resp,totalDist+minA1);
    resp = min(resp,totalDist+minB1);

    for (unsigned int i = 0; i < n; i += 1)
    {
    	if(i != ia)
    		resp = min(resp,(totalDist+minA1)+vB[i]);
    	if(i != ib)
    		resp = min(resp,(totalDist+minB1)+vA[i]);
    }

    printf("%.12lf\n",resp);

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second

using namespace std;

double dist(pair< long int, long int> a, pair<long int, long int> b)
{
    return sqrt((double)((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s)));
}

int main()
{
    pair<long int, long int> a, b, t;

    cin >> a.f >> a.s >> b.f >> b.s >> t.f >> t.s;

    int n;

    cin >> n;

    vector<pair<long int, long int> > v(n+1,mp(0,0));
    vector<double> d(n+1,0.0);
    vector<double> vA(n+1,0.0);
    vector<double> vB(n+1,0.0);
    double totalDist = 0.0;
    double minA1 = DBL_MAX,minA2 = DBL_MAX, minB1 = DBL_MAX, minB2 = DBL_MAX;
    int ia, ib;

    for(unsigned int i = 0; i < n; i++)
    {
        cin >> v[i].f >> v[i].s;

 		d[i] = dist(t,v[i]);

 		vA[i] = dist(a,v[i]) - d[i];
 		vB[i] = dist(b,v[i]) - d[i];

        totalDist += 2.0*d[i];
    }

    for (unsigned int i = 0; i < n; i += 1)
    {

 		if(vA[i] < minA1)
 		{
 			minA1 = min(minA1,vA[i]);
 			ia = i;
 		}

 		if(vB[i] < minB1)
 		{
 			minB1 = min(minB1,vB[i]);
 			ib = i;
 		}
    }

    double resp = HUGE_VAL;

    resp = min(resp,totalDist+minA1);
    resp = min(resp,totalDist+minB1);

    for (unsigned int i = 0; i < n; i += 1)
    {
    	if(i != ia)
    		resp = min(resp,(totalDist+minA1)+vB[i]);
    	if(i != ib)
    		resp = min(resp,(totalDist+minB1)+vA[i]);
    }

    printf("%.15lf\n",resp);

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second

using namespace std;

double dist(pair< double, double> a, pair<double, double> b)
{
    return sqrt((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s));
}

int main()
{
    pair<long int, long int> a, b, t;

    cin >> a.f >> a.s >> b.f >> b.s >> t.f >> t.s;

    int n;

    cin >> n;

    vector<pair<double, double> > v(n+1,mp(0,0));
    vector<double> d(n+1,0.0);
    vector<double> vA(n+1,0.0);
    vector<double> vB(n+1,0.0);
    double totalDist = 0.0;
    double minA1 = DBL_MAX,minA2 = DBL_MAX, minB1 = DBL_MAX, minB2 = DBL_MAX;
    unsigned int ia, ib;

    for(unsigned int i = 0; i < n; i++)
    {
        cin >> v[i].f >> v[i].s;

 		d[i] = dist(t,v[i]);

 		vA[i] = dist(a,v[i]) - d[i];
 		vB[i] = dist(b,v[i]) - d[i];

        totalDist += 2.0*d[i];
    }

    for (unsigned int i = 0; i < n; i += 1)
    {

 		if(vA[i] < minA1)
 		{
 			minA1 = min(minA1,vA[i]);
 			ia = i;
 		}

 		if(vB[i] < minB1)
 		{
 			minB1 = min(minB1,vB[i]);
 			ib = i;
 		}
    }

    double resp = HUGE_VAL;

    resp = min(resp,totalDist+minA1);
    resp = min(resp,totalDist+minB1);

    for (unsigned int i = 0; i < n; i += 1)
    {
    	if(i != ia)
    		resp = min(resp,(totalDist+minA1)+vB[i]);
    	if(i != ib)
    		resp = min(resp,(totalDist+minB1)+vA[i]);
    }

    printf("%.12lf\n",resp);

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second

using namespace std;

double dist(pair< long int, long int> a, pair<long int, long int> b)
{
    return sqrt((double)((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s)));
}

int main()
{
    pair<long int, long int> a, b, t;

    cin >> a.f >> a.s >> b.f >> b.s >> t.f >> t.s;

    int n;

    cin >> n;

    vector<pair<long int, long int> > v(n+1,mp(0,0));
    vector<double> d(n+1,0.0);
    vector<double> vA(n+1,0.0);
    vector<double> vB(n+1,0.0);
    double totalDist = 0.0;
    double minA1 = DBL_MAX,minA2 = DBL_MAX, minB1 = DBL_MAX, minB2 = DBL_MAX;
    int ia, ib;

    for(int i = 0; i < n; i++)
    {
        cin >> v[i].f >> v[i].s;

 		d[i] = dist(t,v[i]);
 		vA[i] = dist(a,v[i]) - d[i];

 		if(vA[i] < minA1)
 		{
 			minA1 = min(minA1,vA[i]);
 			ia = i;
 		}

 		vB[i] = dist(b,v[i]) - d[i];

 		if(vB[i] < minB1)
 		{
 			minB1 = min(minB1,vB[i]);
 			ib = i;
 		}

        totalDist += 2.0*d[i];
    }

    double resp = HUGE_VAL;

    resp = min(resp,totalDist+minA1);
    resp = min(resp,totalDist+minB1);

    for (unsigned int i = 0; i < n; i += 1)
    {
    	if(i != ia)
    		resp = min(resp,(totalDist+minA1)+vB[i]);
    	if(i != ib)
    		resp = min(resp,(totalDist+minB1)+vA[i]);
    }

    printf("%.15lf\n",resp);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

double sqrt12( unsigned long N )
{
    double n, p, low, high;
    if( 2 > N )
        return( N );
    low  = 0;
    high = N;
    while( high > low + 1 )
    {
        n = (high + low) / 2;
        p = n * n;
        if( N < p )
            high = n;
        else if( N > p )
            low = n;
        else
            break;
    }
    return( N == p ? n : low );
}

double dist(pair<int,int> a, pair<int, int> b)
{
	return sqrt12((unsigned long)((a.first-b.first)*(a.first-b.first) + (a.second-b.second)*(a.second-b.second)));
}

int main (int argc, char const* argv[])
{
	int ax, ay, bx, by, tx, ty;

	cin >> ax >> ay >> bx >> by >> tx >> ty;

	int n;
	double distTotal = 0.0;

	cin >> n;

	double minA = DBL_MAX, minB = DBL_MAX;
	int pA = 0, pB = 0;

	vector<pair<int, int> > v(n,make_pair(0,0));

	for(int i = 0; i < n; i++)
	{
		cin >> v[i].first >> v[i].second;
		distTotal += double(2.0)*dist(make_pair(tx,ty),v[i]);

		if(dist(make_pair(ax,ay),v[i]) < minA)
		{
			minA = dist(make_pair(ax,ay),v[i]);
			pA = i;
		}
	}

	for (unsigned int i = 0; i < n; i += 1)
	{
		if(dist(make_pair(bx,by),v[i]) < minB && i != pA)
		{
			minB = dist(make_pair(bx,by),v[i]);
			pB = i;
		}
	}

	distTotal -= dist(make_pair(tx,ty),v[pA]);
	distTotal -= dist(make_pair(tx,ty),v[pB]);
	distTotal += minA + minB;

	printf("%.12lf\n",distTotal);

	return 0;
}


#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll = long long;
using coor = pair<ll, ll>;

long double Dist2Points(const coor &a, const coor &b)
{
	long long dx = a.first - b.first;
	long long dy = a.second - b.second;

	return sqrtl(dx * dx + dy * dy);
}

int main(int argc, char *argv[])
{
	vector<pair<long double, ll>> asaves, bsaves; //collection of the distance from (garb to point) - (a|b to point)
	coor a, b, garb;
	ll n;
	long double distance = 0;
	vector<coor> trash; //bool used to keep track of if already seen

	cin >> a.first >> a.second >> b.first >> b.second >> garb.first >> garb.second;
	cin >> n;
	for (ll i = 0; i < n; ++i)
	{
		coor tmp;
		cin >> tmp.first >> tmp.second;
		trash.push_back(tmp);

		distance += Dist2Points(tmp, garb) * 2;

		long double tmpASave = Dist2Points(a, tmp) - Dist2Points(garb, tmp);
		long double tmpBSave = Dist2Points(b, tmp) - Dist2Points(garb, tmp);

		asaves.push_back(make_pair(tmpASave, i));
		bsaves.push_back(make_pair(tmpBSave, i));
	}

	// Sort them from least saved to most saved, saved only if its >0
	sort(asaves.begin(), asaves.end());
	sort(bsaves.begin(), bsaves.end());

	vector<long double> faces;

	for (auto &ta : asaves)
	{
		for (auto &tb : bsaves)
		{
			if (!faces.size() || (ta.second != tb.second && (ta.first + tb.first < faces[0])))
			{
				faces.push_back(ta.first + tb.first);
			}
		}
		faces.push_back(ta.first);
	}
	for (auto &tb : bsaves)
	{
		faces.push_back(tb.first);
	}
	sort(faces.begin(), faces.end());
	distance += faces[0];

	std::cout << std::fixed;
	cout << std::setprecision(12) << distance << endl;
}


#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll = long long;
using coor = pair<ll, ll>;

long double Dist2Points(const coor &a, const coor &b)
{
	long long dx = abs(a.first - b.first);
	long long dy = abs(a.second - b.second);

	return sqrtl(dx * dx + dy * dy);
}

int main(int argc, char *argv[])
{
	vector<pair<long double, ll>> asaves, bsaves; //collection of the distance from (garb to point) - (a|b to point)
	coor a, b, garb;
	ll n;
	vector<pair<coor, bool>> trash; //bool used to keep track of if already seen

	cin >> a.first >> a.second >> b.first >> b.second >> garb.first >> garb.second;
	cin >> n;
	for (ll i = 0; i < n; ++i)
	{
		coor tmp;
		cin >> tmp.first >> tmp.second;
		trash.push_back(make_pair(tmp, false));

		long double tmpASave = Dist2Points(garb, tmp) - Dist2Points(a, tmp);
		long double tmpBSave = Dist2Points(garb, tmp) - Dist2Points(b, tmp);

		asaves.push_back(make_pair(tmpASave, i));
		bsaves.push_back(make_pair(tmpBSave, i));
	}

	// Sort them from least saved to most saved, saved only if its >0
	sort(asaves.begin(), asaves.end());
	sort(bsaves.begin(), bsaves.end());

	long double distance = 0;

	vector<pair<long double, pair<ll, ll>>> faces;

	// Determine the 4 cases;
	if (asaves[n - 1].first < 0 && bsaves[n - 1].first < 0) //None saved case
	{
		//Determine the least distant path
		pair<long double, ll> &biggerDist = asaves[n - 1].first > bsaves[n - 1].first ? asaves[n - 1] : bsaves[n - 1];
		trash[biggerDist.second].second = true;
		distance += Dist2Points(trash[biggerDist.second].first, garb) * 2 - biggerDist.first;
	}
	else
	{
		if (asaves[n - 1].second == bsaves[n - 1].second)
		{
			if (n - 2 >= 0)
			{
				if (asaves[n - 2].first > 0)
				{
					faces.push_back(make_pair(asaves[n - 1].first, make_pair(asaves[n - 1].second, -1)));
					faces.push_back(make_pair(bsaves[n - 1].first + asaves[n - 2].first, make_pair(bsaves[n - 1].second, asaves[n - 2].second)));
				}
				if (bsaves[n - 2].first > 0)
				{
					faces.push_back(make_pair(bsaves[n - 1].first, make_pair(bsaves[n - 1].second, -1)));
					faces.push_back(make_pair(asaves[n - 1].first + bsaves[n - 2].first, make_pair(asaves[n - 1].second, bsaves[n - 2].second)));
				}
			}
			else
			{
				faces.push_back(make_pair(asaves[n - 1].first, make_pair(asaves[n - 1].second, -1)));
				faces.push_back(make_pair(bsaves[n - 1].first, make_pair(bsaves[n - 1].second, -1)));
			}
		}
		else
		{
			faces.push_back(make_pair(asaves[n - 1].first + bsaves[n - 1].first, make_pair(asaves[n - 1].second, bsaves[n - 1].second)));
		}

		pair<long double, pair<ll, ll>> &largest = faces[0];
		for (auto &var : faces)
		{
			if (var.first > largest.first)
			{
				largest = var;
			}
		}

		distance = largest.second.second > 0 ? Dist2Points(trash[largest.second.second].first, garb) : 0;
		distance += Dist2Points(trash[largest.second.first].first, garb);
		distance *= 2;
		distance -= largest.first;

		if (largest.second.second > 0)
		{
			trash[largest.second.second].second = true;
		}
		trash[largest.second.first].second = true;
	}

	//else
	//{
	//	vector<pair<long double, ll>> &lowerSave = asaves;

	//	if (asaves[n - 1].second == bsaves[n - 1].second)
	//	{
	//		if (asaves[n - 2].first > 0 && bsaves[n - 2].first > 0)
	//		{
	//			long double afirst = asaves[n - 1].first + bsaves[n - 2].first;
	//			long double bfirst = bsaves[n - 1].first + asaves[n - 2].first;

	//			if (afirst > bfirst)
	//			{
	//				distance += Dist2Points(trash[asaves[n - 1].second].first, garb) * 2 - asaves[n - 1].first;
	//				distance += Dist2Points(trash[bsaves[n - 2].second].first, garb) * 2 - bsaves[n - 2].first;
	//				trash[asaves[n - 1].second].second = true;
	//				trash[bsaves[n - 2].second].second = true;
	//			}
	//			else
	//			{
	//				distance += Dist2Points(trash[asaves[n - 2].second].first, garb) * 2 - asaves[n - 2].first;
	//				distance += Dist2Points(trash[bsaves[n - 1].second].first, garb) * 2 - bsaves[n - 1].first;
	//				trash[asaves[n - 2].second].second = true;
	//				trash[bsaves[n - 1].second].second = true;
	//			}
	//		}
	//		else if (asaves[n - 2].first < 0 && bsaves[n - 2].first < 0)
	//		{
	//			if (asaves[n - 1].first > bsaves[n - 1].first)
	//			{
	//				distance += Dist2Points(trash[asaves[n - 1].second].first, garb) * 2 - asaves[n - 1].first;
	//				trash[asaves[n - 1].second].second = true;
	//			}
	//			else
	//			{
	//				distance += Dist2Points(trash[bsaves[n - 1].second].first, garb) * 2 - bsaves[n - 1].first;
	//				trash[bsaves[n - 1].second].second = true;
	//			}
	//		}
	//		else if (asaves[n - 2].first > 0)
	//		{
	//			distance += Dist2Points(trash[asaves[n - 2].second].first, garb) * 2 - asaves[n - 2].first;
	//			distance += Dist2Points(trash[bsaves[n - 1].second].first, garb) * 2 - bsaves[n - 1].first;
	//			trash[asaves[n - 2].second].second = true;
	//			trash[bsaves[n - 1].second].second = true;
	//		}
	//		else
	//		{
	//			distance += Dist2Points(trash[asaves[n - 1].second].first, garb) * 2 - asaves[n - 1].first;
	//			distance += Dist2Points(trash[bsaves[n - 2].second].first, garb) * 2 - bsaves[n - 2].first;
	//			trash[asaves[n - 1].second].second = true;
	//			trash[bsaves[n - 2].second].second = true;
	//		}
	//	}
	//	else
	//	{
	//		if (asaves[n - 1].first > bsaves[n - 1].first)
	//		{
	//			lowerSave = bsaves;
	//			trash[asaves[n - 1].second].second = true;
	//			distance += Dist2Points(trash[asaves[n - 1].second].first, garb) * 2 - asaves[n - 1].first;
	//		}
	//		else
	//		{
	//			lowerSave = asaves;
	//			trash[bsaves[n - 1].second].second = true;
	//			distance += Dist2Points(trash[bsaves[n - 1].second].first, garb) * 2 - bsaves[n - 1].first;
	//		}

	//		for (int i = n - 1; lowerSave[i].first > 0; --i)
	//		{
	//			if (trash[lowerSave[i].second].second) continue; //if already seen
	//			trash[lowerSave[i].second].second = true;
	//			distance += Dist2Points(trash[lowerSave[i].second].first, garb) * 2 - lowerSave[i].first;
	//			break;
	//		}
	//	}
	//}

	for (auto &var : trash)
	{
		if (var.second) continue;
		distance += Dist2Points(var.first, garb) * 2;
	}
	std::cout << std::fixed;
	cout << std::setprecision(12) << distance << endl;
}


#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll = long long;
using coor = pair<ll, ll>;

long double Dist2Points(const coor &a, const coor &b)
{
	long long dx = a.first - b.first;
	long long dy = a.second - b.second;

	return sqrtl(dx * dx + dy * dy);
}

int main(int argc, char *argv[])
{
	vector<pair<long double, ll>> asaves, bsaves; //collection of the distance from (garb to point) - (a|b to point)
	coor a, b, garb;
	ll n;
	long double distance = 0;
	vector<coor> trash; //bool used to keep track of if already seen

	cin >> a.first >> a.second >> b.first >> b.second >> garb.first >> garb.second;
	cin >> n;
	for (ll i = 0; i < n; ++i)
	{
		coor tmp;
		cin >> tmp.first >> tmp.second;
		trash.push_back(tmp);

		distance += Dist2Points(tmp, garb) * 2;

		long double tmpASave = Dist2Points(a, tmp) - Dist2Points(garb, tmp);
		long double tmpBSave = Dist2Points(b, tmp) - Dist2Points(garb, tmp);

		asaves.push_back(make_pair(tmpASave, i));
		bsaves.push_back(make_pair(tmpBSave, i));
	}

	// Sort them from least saved to most saved, saved only if its >0
	sort(asaves.begin(), asaves.end());
	sort(bsaves.begin(), bsaves.end());

	vector<long double> faces;

	for (auto &ta : asaves)
	{
		for (auto &tb : bsaves)
		{
			if (ta.second != tb.second)
			{
				faces.push_back(ta.first + tb.first);
			}
		}
		faces.push_back(ta.first);
	}
	for (auto &tb : bsaves)
	{
		faces.push_back(tb.first);
	}
	sort(faces.begin(), faces.end());
	distance += faces[0];

	std::cout << std::fixed;
	cout << std::setprecision(12) << distance << endl;
}


#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll = long long;
using coor = pair<ll, ll>;

long double Dist2Points(const coor &a, const coor &b)
{
	long long dx = abs(a.first - b.first);
	long long dy = abs(a.second - b.second);

	return sqrtl(dx * dx + dy * dy);
}

int main(int argc, char *argv[])
{
	vector<pair<long double, ll>> asaves, bsaves; //collection of the distance from (garb to point) - (a|b to point)
	coor a, b, garb;
	ll n;
	vector<pair<coor, bool>> trash; //bool used to keep track of if already seen

	cin >> a.first >> a.second >> b.first >> b.second >> garb.first >> garb.second;
	cin >> n;
	for (ll i = 0; i < n; ++i)
	{
		coor tmp;
		cin >> tmp.first >> tmp.second;
		trash.push_back(make_pair(tmp, false));

		long double tmpASave = Dist2Points(garb, tmp) - Dist2Points(a, tmp);
		long double tmpBSave = Dist2Points(garb, tmp) - Dist2Points(b, tmp);

		asaves.push_back(make_pair(tmpASave, i));
		bsaves.push_back(make_pair(tmpBSave, i));
	}

	// Sort them from least saved to most saved, saved only if its >0
	sort(asaves.begin(), asaves.end());
	sort(bsaves.begin(), bsaves.end());

	long double distance = 0;

	// Determine the 4 cases;
	if (asaves[n - 1].first < 0 && bsaves[n - 1].first < 0) //None saved case
	{
		//Determine the least distant path
		pair<long double, ll> &biggerDist = asaves[n - 1].first > bsaves[n - 1].first ? asaves[n - 1] : bsaves[n - 1];
		trash[biggerDist.second].second = true;
		distance += Dist2Points(trash[biggerDist.second].first, garb) * 2 - biggerDist.first;
	}
	else
	{
		vector<pair<long double, ll>> &lowerSave = asaves;

		if (asaves[n - 1].second == bsaves[n - 1].second)
		{
			if (asaves[n - 2].first > 0 && bsaves[n - 2].first > 0)
			{
				long double afirst = asaves[n - 1].first + bsaves[n - 2].first;
				long double bfirst = bsaves[n - 1].first + asaves[n - 2].first;

				if (afirst > bfirst)
				{
					distance += Dist2Points(trash[asaves[n - 1].second].first, garb) * 2 - asaves[n - 1].first;
					distance += Dist2Points(trash[bsaves[n - 2].second].first, garb) * 2 - bsaves[n - 2].first;
					trash[asaves[n - 1].second].second = true;
					trash[bsaves[n - 2].second].second = true;
				}
				else
				{
					distance += Dist2Points(trash[asaves[n - 2].second].first, garb) * 2 - asaves[n - 2].first;
					distance += Dist2Points(trash[bsaves[n - 1].second].first, garb) * 2 - bsaves[n - 1].first;
					trash[asaves[n - 2].second].second = true;
					trash[bsaves[n - 1].second].second = true;
				}
			}
			else if (asaves[n - 2].first < 0 && bsaves[n - 2].first < 0)
			{
				if (asaves[n - 1].first > bsaves[n - 1].first)
				{
					distance += Dist2Points(trash[asaves[n - 1].second].first, garb) * 2 - asaves[n - 1].first;
					trash[asaves[n - 1].second].second = true;
				}
				else
				{
					distance += Dist2Points(trash[bsaves[n - 1].second].first, garb) * 2 - bsaves[n - 1].first;
					trash[bsaves[n - 1].second].second = true;
				}
			}
			else if (asaves[n - 2].first > 0)
			{
				distance += Dist2Points(trash[asaves[n - 2].second].first, garb) * 2 - asaves[n - 2].first;
				distance += Dist2Points(trash[bsaves[n - 1].second].first, garb) * 2 - bsaves[n - 1].first;
				trash[asaves[n - 2].second].second = true;
				trash[bsaves[n - 1].second].second = true;
			}
			else
			{
				distance += Dist2Points(trash[asaves[n - 1].second].first, garb) * 2 - asaves[n - 1].first;
				distance += Dist2Points(trash[bsaves[n - 2].second].first, garb) * 2 - bsaves[n - 2].first;
				trash[asaves[n - 1].second].second = true;
				trash[bsaves[n - 2].second].second = true;
			}
		}
		else
		{
			if (asaves[n - 1].first > bsaves[n - 1].first)
			{
				lowerSave = bsaves;
				trash[asaves[n - 1].second].second = true;
				distance += Dist2Points(trash[asaves[n - 1].second].first, garb) * 2 - asaves[n - 1].first;
			}
			else
			{
				lowerSave = asaves;
				trash[bsaves[n - 1].second].second = true;
				distance += Dist2Points(trash[bsaves[n - 1].second].first, garb) * 2 - bsaves[n - 1].first;
			}

			for (int i = n - 1; lowerSave[i].first > 0; --i)
			{
				if (trash[lowerSave[i].second].second) continue; //if already seen
				trash[lowerSave[i].second].second = true;
				distance += Dist2Points(trash[lowerSave[i].second].first, garb) * 2 - lowerSave[i].first;
				break;
			}
		}
	}

	for (auto &var : trash)
	{
		if (var.second) continue;
		distance += Dist2Points(var.first, garb) * 2;
	}
	std::cout << std::fixed;
	cout << std::setprecision(12) << distance << endl;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using coor = pair<long long, long long>;

long double py(coor src, coor dest)
{
	return sqrtl(powl(abs(src.first - dest.first), 2.0) + powl(abs(src.second - dest.second), 2.0));
}

long double dissv(coor ab, coor garb, coor gb)
{
	long double garbd = py(gb, garb) * 2;
	long double abd = py(ab, garb) + py(gb, garb);
	return garbd - abd;
}

int main(int argc, char *argv[])
{
	coor a, b, gb;
	int n;
	vector<coor> arr;

	cin >> a.first >> a.second >> b.first >> b.second >> gb.first >> gb.second >> n;

	while (n--)
	{
		long long x, y;
		cin >> x >> y;
		arr.push_back(make_pair(x, y));
	}

	long double dist = 0.0, asaved = dissv(a, arr[0], gb), bsaved = dissv(b, arr[0], gb);
	int leastinda = 0, leastindb = 0;

	for (decltype(arr.size()) i = 0; i < arr.size(); ++i)
	{
		if (asaved < dissv(a, arr[i], gb))
		{
			leastinda = i;
			asaved = dissv(a, arr[i], gb);
		}
		if (bsaved < dissv(b, arr[i], gb))
		{
			leastindb = i;
			bsaved = dissv(b, arr[i], gb);
		}
	}

	if (asaved > bsaved)
	{
		dist += py(gb, arr[leastinda]) + py(a, arr[leastinda]);
		arr.erase(arr.begin() + leastinda);
		a = gb;
	}
	else
	{
		dist += py(gb, arr[leastindb]) + py(b, arr[leastindb]);
		arr.erase(arr.begin() + leastindb);
		b = gb;
	}

	/*if (leasta < leastb)
	{
		dist += leasta;
		arr.erase(arr.begin() + leastinda);
		a = gb;
	}
	else
	{
		dist += leastb;
		arr.erase(arr.begin() + leastindb);
		b = gb;
	}*/

	for (const auto &var : arr)
	{
		if (dissv(a, var, gb) > dissv(b, var, gb))
		{
			dist += py(a, var) + py(gb, var);
			a = gb;
		}
		else
		{
			dist += py(b, var) + py(gb, var);
			b = gb;
		}
	}

	cout << dist << endl;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

using coor = pair<long long, long long>;

long double py(coor src, coor dest)
{
	return sqrtl(powl(abs(src.first - dest.first), static_cast<long double>(2.0)) + powl(abs(src.second - dest.second), static_cast<long double>(2.0)));
}

long double dissv(coor ab, coor garb, coor gb)
{
	long double garbd = py(gb, garb) * static_cast<long long>(2);
	long double abd = py(ab, garb) + py(gb, garb);
	return garbd - abd;
}

int main(int argc, char *argv[])
{
	coor a, b, gb;
	long long n;
	vector<coor> arr;

	cin >> a.first >> a.second >> b.first >> b.second >> gb.first >> gb.second >> n;

	while (n--)
	{
		long long x, y;
		cin >> x >> y;
		arr.push_back(make_pair(x, y));
	}

	long double dist = 0, asaved = dissv(a, arr[0], gb), bsaved = dissv(b, arr[0], gb);
	long long leastinda = 0, leastindb = 0;

	for (decltype(arr.size()) i = 0; i < arr.size(); ++i)
	{
		if (asaved < dissv(a, arr[i], gb))
		{
			leastinda = i;
			asaved = dissv(a, arr[i], gb);
		}
		if (bsaved < dissv(b, arr[i], gb))
		{
			leastindb = i;
			bsaved = dissv(b, arr[i], gb);
		}
	}

	if (asaved > bsaved)
	{
		dist += py(gb, arr[leastinda]) + py(a, arr[leastinda]);
		arr.erase(arr.begin() + leastinda);
		a = gb;
	}
	else
	{
		dist += py(gb, arr[leastindb]) + py(b, arr[leastindb]);
		arr.erase(arr.begin() + leastindb);
		b = gb;
	}

	/*if (leasta < leastb)
	{
		dist += leasta;
		arr.erase(arr.begin() + leastinda);
		a = gb;
	}
	else
	{
		dist += leastb;
		arr.erase(arr.begin() + leastindb);
		b = gb;
	}*/

	for (const auto &var : arr)
	{
		if (dissv(a, var, gb) > dissv(b, var, gb))
		{
			dist += py(a, var) + py(gb, var);
			a = gb;
		}
		else
		{
			dist += py(b, var) + py(gb, var);
			b = gb;
		}
	}
	std::cout << std::fixed;
	cout << std::setprecision(12) << dist << endl;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using coor = pair<long long, long long>;

long double py(coor src, coor dest)
{
	return sqrt(pow(abs(src.first - dest.first), 2.0) + pow(abs(src.second - dest.second), 2.0));
}

int main(int argc, char *argv[])
{
	coor a, b, gb;
	int n;
	vector<coor> arr;

	cin >> a.first >> a.second >> b.first >> b.second >> gb.first >> gb.second >> n;

	while (n--)
	{
		int x, y;
		cin >> x >> y;
		arr.push_back(make_pair(x, y));
	}

	long double dist = 0.0;

	for (const auto &var : arr)
	{
		if (py(a, var) < py(b, var))
		{
			dist += py(a, var) + py(var, gb);
			a = gb;
		}
		else
		{
			dist += py(b, var) + py(var, gb);
			b = gb;
		}
	}
	cout << dist << endl;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

using coor = pair<long long, long long>;

long double py(coor src, coor dest)
{
	return sqrt(pow(abs(src.first - dest.first), 2.0) + pow(abs(src.second - dest.second), 2.0));
}

long double dissv(coor ab, coor garb, coor gb)
{
	long double garbd = py(gb, garb) * 2;
	long double abd = py(ab, garb) + py(gb, garb);
	return garbd - abd;
}

int main(int argc, char *argv[])
{
	coor a, b, gb;
	int n;
	vector<coor> arr;

	cin >> a.first >> a.second >> b.first >> b.second >> gb.first >> gb.second >> n;

	while (n--)
	{
		long long x, y;
		cin >> x >> y;
		arr.push_back(make_pair(x, y));
	}

	long double dist = 0.0, asaved = dissv(a, arr[0], gb), bsaved = dissv(b, arr[0], gb);
	int leastinda = 0, leastindb = 0;

	for (decltype(arr.size()) i = 0; i < arr.size(); ++i)
	{
		if (asaved < dissv(a, arr[i], gb))
		{
			leastinda = i;
			asaved = dissv(a, arr[i], gb);
		}
		if (bsaved < dissv(b, arr[i], gb))
		{
			leastindb = i;
			bsaved = dissv(b, arr[i], gb);
		}
	}

	if (asaved > bsaved)
	{
		dist += py(gb, arr[leastinda]) + py(a, arr[leastinda]);
		arr.erase(arr.begin() + leastinda);
		a = gb;
	}
	else
	{
		dist += py(gb, arr[leastindb]) + py(b, arr[leastindb]);
		arr.erase(arr.begin() + leastindb);
		b = gb;
	}

	/*if (leasta < leastb)
	{
		dist += leasta;
		arr.erase(arr.begin() + leastinda);
		a = gb;
	}
	else
	{
		dist += leastb;
		arr.erase(arr.begin() + leastindb);
		b = gb;
	}*/

	for (const auto &var : arr)
	{
		if (dissv(a, var, gb) > dissv(b, var, gb))
		{
			dist += py(a, var) + py(gb, var);
			a = gb;
		}
		else
		{
			dist += py(b, var) + py(gb, var);
			b = gb;
		}
	}
	std::cout << std::fixed;
	cout << std::setprecision(12) << dist << endl;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

using coor = pair<long long, long long>;

long double py(coor src, coor dest)
{
	return sqrtl(powl(abs(src.first - dest.first), 2.0) + powl(abs(src.second - dest.second), 2.0));
}

long double dissv(coor ab, coor garb, coor gb)
{
	long double garbd = py(gb, garb) * 2;
	long double abd = py(ab, garb) + py(gb, garb);
	return garbd - abd;
}

int main(int argc, char *argv[])
{
	coor a, b, gb;
	long long n;
	vector<coor> arr;

	cin >> a.first >> a.second >> b.first >> b.second >> gb.first >> gb.second >> n;

	while (n--)
	{
		long long x, y;
		cin >> x >> y;
		arr.push_back(make_pair(x, y));
	}

	long double dist = 0.0, asaved = dissv(a, arr[0], gb), bsaved = dissv(b, arr[0], gb);
	long long leastinda = 0, leastindb = 0;

	for (decltype(arr.size()) i = 0; i < arr.size(); ++i)
	{
		if (asaved < dissv(a, arr[i], gb))
		{
			leastinda = i;
			asaved = dissv(a, arr[i], gb);
		}
		if (bsaved < dissv(b, arr[i], gb))
		{
			leastindb = i;
			bsaved = dissv(b, arr[i], gb);
		}
	}

	if (asaved > bsaved)
	{
		dist += py(gb, arr[leastinda]) + py(a, arr[leastinda]);
		arr.erase(arr.begin() + leastinda);
		a = gb;
	}
	else
	{
		dist += py(gb, arr[leastindb]) + py(b, arr[leastindb]);
		arr.erase(arr.begin() + leastindb);
		b = gb;
	}

	/*if (leasta < leastb)
	{
		dist += leasta;
		arr.erase(arr.begin() + leastinda);
		a = gb;
	}
	else
	{
		dist += leastb;
		arr.erase(arr.begin() + leastindb);
		b = gb;
	}*/

	for (const auto &var : arr)
	{
		if (dissv(a, var, gb) > dissv(b, var, gb))
		{
			dist += py(a, var) + py(gb, var);
			a = gb;
		}
		else
		{
			dist += py(b, var) + py(gb, var);
			b = gb;
		}
	}
	std::cout << std::fixed;
	cout << std::setprecision(12) << dist << endl;
}


#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll = long long;
using coor = pair<ll, ll>;

long double Dist2Points(const coor &a, const coor &b)
{
	long long dx = a.first - b.first;
	long long dy = a.second - b.second;

	return sqrtl(dx * dx + dy * dy);
}

int main(int argc, char *argv[])
{
	vector<pair<long double, ll>> asaves, bsaves; //collection of the distance from (garb to point) - (a|b to point)
	coor a, b, garb;
	ll n;
	long double distance = 0;
	vector<coor> trash; //bool used to keep track of if already seen

	cin >> a.first >> a.second >> b.first >> b.second >> garb.first >> garb.second;
	cin >> n;
	for (ll i = 0; i < n; ++i)
	{
		coor tmp;
		cin >> tmp.first >> tmp.second;
		trash.push_back(tmp);

		distance += Dist2Points(tmp, garb) * 2;

		long double tmpASave = Dist2Points(a, tmp) - Dist2Points(garb, tmp);
		long double tmpBSave = Dist2Points(b, tmp) - Dist2Points(garb, tmp);

		asaves.push_back(make_pair(tmpASave, i));
		bsaves.push_back(make_pair(tmpBSave, i));
	}

	// Sort them from least saved to most saved, saved only if its >0
	sort(asaves.begin(), asaves.end());
	sort(bsaves.begin(), bsaves.end());

	vector<long double> faces;

	for (auto &ta : asaves)
	{
		for (auto &tb : bsaves)
		{
			if (ta.second != tb.second)
			{
				faces.push_back(ta.first + tb.first);
				break;
			}
		}
		faces.push_back(ta.first);
	}
	for (auto &tb : bsaves)
	{
		faces.push_back(tb.first);
	}
	sort(faces.begin(), faces.end());
	distance += faces[0];

	std::cout << std::fixed;
	cout << std::setprecision(12) << distance << endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), [](const pair<double, int> &a, const pair<double, int> &b) { return (a.first > b.first); });

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    if (first == second )
        if (dist_a[1].first > dist_b[1].first) {
            first = dist_a[1].second;
            second = dist_b[0].second;
        } else {
            first = dist_a[0].second;
            second = dist_b[0].second;
        }

    double res;
    if (dist_a[0].first > 0 && dist_b[0].first > 0)
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                    dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
    else if (dist_a[0].first > 0/* || (dist_a[0].first < 0 && dist_b[0].first < 0 && dist_a[0].first > dist_b[0].first)*/) {
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty);
        second = -1;
    } else {
        res = dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
        first = -1;
    }

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2 * dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), [](const pair<double, int> &a, const pair<double, int> &b) { return (a.first > b.first); });

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    if (first - second <= numeric_limits<double>::epsilon() )
        if (dist_a[1].first > dist_b[1].first) {
            first = dist_a[1].second;
            second = dist_b[0].second;
        } else {
            first = dist_a[0].second;
            second = dist_b[0].second;
        }

    double res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2 * dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


/*******

You're not you, when you have nothing to do (10x WA)

*******/

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), [](const pair<double, int> &a, const pair<double, int> &b) { return (a.first > b.first); });

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    if (n == 1) {
        cout << setprecision(10) << fixed << min(dist(v[0].first, v[0].second, ax, ay) + dist(v[0].first, v[0].second, tx, ty),
                    dist(v[0].first, v[0].second, bx, by) + dist(v[0].first, v[0].second, tx, ty)) << endl;
        return 0;
    }

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    double first_val = dist_a.front().first, second_val = dist_b.front().first;

    if (first == second )
        if (first_val > 0 && second_val < 0)
            second = -1;
        else if (first_val < 0 && second_val > 0)
            first = -1;
        else if (first_val < 0 && second_val < 0) {
            if (first_val > second_val)
                second = -1;
            else
                first = -1;
        } else if (second_val + dist_a[1].first > first_val + dist_b[1].first) {
            first = dist_a[1].second;
            first_val = dist_a[1].first;
        } else {
            second = dist_b[1].second;
            second_val = dist_b[1].first;
        }

    double res;
    if (first_val > 0 && second_val > 0)
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                    dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
    else if (first_val > 0 || second_val*first_val >= 0 && first_val > second_val) {
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty);
        second = -1;
    } else if (second_val > 0 || second_val*first_val >= 0 && first_val < second_val){
        res = dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
        first = -1;
    } else
        if (dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) <
            dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty)) {
            res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty);
            second = -1;
        } else {
            res = dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
            first = -1;
        }

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2 * dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), [](const pair<double, int> &a, const pair<double, int> &b) { return (a.first > b.first); });

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    double first_val = dist_a.front().first, second_val = dist_b.front().first;

    if (first == second )
        if (first_val > 0 && second_val < 0)
            second = -1;
        else if (first_val < 0 && second_val > 0)
            first = -1;
        else if (first_val < 0 && second_val < 0) {
            if (first_val > second_val)
                second = -1;
            else
                first = -1;
        } else if (second_val + dist_a[1].first > first_val + dist_b[1].first) {
            first = dist_a[1].second;
            first_val = dist_a[1].first;
        } else {
            second = dist_b[1].second;
            second_val = dist_b[1].first;
        }

    double res;
    if (first_val > 0 && second_val > 0)
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                    dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
    else if (first_val > 0 || second_val*first_val > 0 && first_val > second_val) {
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty);
        second = -1;
    } else if (second_val > 0 || second_val*first_val > 0 && first_val < second_val){
        res = dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
        first = -1;
    }

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2 * dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(2*dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), [](const pair<double, int> &a, const pair<double, int> &b) { return (a.first > b.first); });

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    if (first - second <= numeric_limits<double>::epsilon() )
        if (dist_a[1].first > dist_b[1].first) {
            first = dist_a[1].second;
            second = dist_b[0].second;
        } else {
            first = dist_a[0].second;
            second = dist_b[0].second;
        }

    double res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2 * dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), [](const pair<double, int> &a, const pair<double, int> &b) { return (a.first > b.first); });

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    double first_val = dist_a.front().first, second_val = dist_b.front().first;
    if (first == second )
        if (first_val > 0 && second_val < 0)
            second = -1;
        else if (first_val < 0 && second_val > 0)
            first = -1;
        else if (first_val < 0 && second_val < 0) {
            if (first_val > second_val)
                second = -1;
            else
                first = -1;
        } else if (dist_a[1].first > dist_b[1].first) {
            first = dist_a[1].second;
            first_val = dist_a[1].first;
        } else {
            second = dist_b[1].second;
            second_val = dist_b[1].first;
        }

    double res;
    if (first_val > 0 && second_val > 0)
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                    dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
    else if (first_val > 0 || second_val*first_val > 0 && first_val > second_val) {
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty);
        second = -1;
    } else if (second_val > 0 || second_val*first_val > 0 && first_val < second_val){
        res = dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
        first = -1;
    }

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2 * dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), [](const pair<double, int> &a, const pair<double, int> &b) { return (a.first > b.first); });

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    if (n == 1) {
        cout << setprecision(10) << fixed << min(dist(v[0].first, v[0].second, ax, ay) + dist(v[0].first, v[0].second, tx, ty),
                    dist(v[0].first, v[0].second, bx, by) + dist(v[0].first, v[0].second, tx, ty)) << endl;
        return 0;
    }

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    double first_val = dist_a.front().first, second_val = dist_b.front().first;

    if (first == second )
        if (first_val > 0 && second_val < 0)
            second = -1;
        else if (first_val < 0 && second_val > 0)
            first = -1;
        else if (first_val < 0 && second_val < 0) {
            if (first_val > second_val)
                second = -1;
            else
                first = -1;
        } else if (second_val + dist_a[1].first > first_val + dist_b[1].first) {
            first = dist_a[1].second;
            first_val = dist_a[1].first;
        } else {
            second = dist_b[1].second;
            second_val = dist_b[1].first;
        }

    double res;
    if (first_val > 0 && second_val > 0)
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                    dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
    else if (first_val > 0 || second_val*first_val >= 0 && first_val > second_val) {
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty);
        second = -1;
    } else if (second_val > 0 || second_val*first_val >= 0 && first_val < second_val){
        res = dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
        first = -1;
    }

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2 * dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), [](const pair<double, int> &a, const pair<double, int> &b) { return (a.first > b.first); });

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    double first_val = dist_a.front().first, second_val = dist_b.front().first;

    if (first == second )
        if (first_val > 0 && second_val < 0)
            second = -1;
        else if (first_val < 0 && second_val > 0)
            first = -1;
        else if (first_val < 0 && second_val < 0) {
            if (first_val > second_val)
                second = -1;
            else
                first = -1;
        } else if (second_val + dist_a[1].first > first_val + dist_b[1].first) {
            first = dist_a[1].second;
            first_val = dist_a[1].first;
        } else {
            second = dist_b[1].second;
            second_val = dist_b[1].first;
        }

    double res;
    if (first_val > 0 && second_val > 0)
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                    dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
    else if (first_val > 0 || second_val*first_val >= 0 && first_val > second_val) {
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty);
        second = -1;
    } else if (second_val > 0 || second_val*first_val >= 0 && first_val < second_val){
        res = dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
        first = -1;
    }

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2 * dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), greater<pair<double, int> >());

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    if (first == second)
        if (dist_a[1].first >= dist_b[1].first) {
            first = dist_a[1].second;
            second = dist_b[0].second;
        } else {
            first = dist_a[0].second;
            second = dist_b[0].second;
        }

    double res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2*dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot + dist_start_urn, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), greater<pair<double, int> >());

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    if (first == second)
        if (dist_a[1].first >= dist_b[1].first) {
            first = dist_a[1].second;
            second = dist_b[0].second;
        } else {
            first = dist_a[0].second;
            second = dist_b[0].second;
        }

    double res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2*dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


/*******

You're not you, when you have nothing to do (11x WA)
I do not like crutches, but I'm too lazy to write without them ;)

*******/

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), [](const pair<double, int> &a, const pair<double, int> &b) { return (a.first > b.first); });

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    if (n == 1) {
        cout << setprecision(10) << fixed << min(dist(v[0].first, v[0].second, ax, ay) + dist(v[0].first, v[0].second, tx, ty),
                    dist(v[0].first, v[0].second, bx, by) + dist(v[0].first, v[0].second, tx, ty)) << endl;
        return 0;
    }

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    double first_val = dist_a.front().first, second_val = dist_b.front().first;

    if (first == second )
        if (first_val >= 0 && second_val <= 0)
            second = -1;
        else if (first_val <= 0 && second_val >= 0)
            first = -1;
        else if (first_val <= 0 && second_val <= 0) {
            if (first_val > second_val)
                second = -1;
            else
                first = -1;
        } else if (second_val + dist_a[1].first >= first_val + dist_b[1].first || dist_b[1].first == 0) {
            first = dist_a[1].second;
            first_val = dist_a[1].first;
        } else {
            second = dist_b[1].second;
            second_val = dist_b[1].first;
        }

    double res;
    if (first_val >= 0 && second_val >= 0)
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                    dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
    else if (first_val >= 0 || second_val*first_val >= 0 && first_val > second_val) {
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty);
        second = -1;
    } else if (second_val >= 0 || second_val*first_val >= 0 && first_val < second_val){
        res = dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
        first = -1;
    } else
        if (dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) <
            dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty)) {
            res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty);
            second = -1;
        } else {
            res = dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
            first = -1;
        }

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
           continue;

        res += 2 * dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;

double dist(int ax, int ay, int bx, int by)
{
    return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
}

class Calculator
{
public:
    Calculator(int a, int b, int c, int d) : ax(a), ay(b), tx(c), ty(d), i(0)
    {
        dist_start_urn = dist(ax, ay, tx, ty);
    }

    pair<double, int> operator() (const pair<int, int> &pos)
    {
        double dist_dot = dist(ax, ay, pos.first, pos.second);
        double dist_urn = dist(pos.first, pos.second, tx, ty);

        return make_pair(dist_urn - dist_dot, i++);
    }
private:
    int ax, ay, tx, ty, i, dist_start_urn;
};

vector<pair<double, int> > calc_differences(const vector<pair<int, int> > &v, int ax, int ay, int tx, int ty)
{
    vector<pair<double, int> > res;

    transform(v.begin(), v.end(), back_inserter(res), Calculator(ax, ay, tx, ty));
    sort(res.begin(), res.end(), [](const pair<double, int> &a, const pair<double, int> &b) { return (a.first > b.first); });

    return res;
}

int main()
{
    int ax, ay, bx, by, tx, ty;
    cin >> ax >> ay >> bx >> by >> tx >> ty;

    int n;
    cin >> n;

    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;

    auto dist_a = calc_differences(v, ax, ay, tx, ty);
    auto dist_b = calc_differences(v, bx, by, tx, ty);

    int first = dist_a.front().second, second = dist_b.front().second;
    if (first == second )
        if (dist_a[1].first > dist_b[1].first) {
            first = dist_a[1].second;
            second = dist_b[0].second;
        } else {
            first = dist_a[0].second;
            second = dist_b[0].second;
        }

    double res;
    if (dist_a[0].first > 0 && dist_b[0].first > 0)
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty) +
                    dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
    else if (dist_a[0].first > 0 || (dist_a[0].first < 0 && dist_b[0].first < 0 && dist_a[0].first > dist_b[0].first)) {
        res = dist(v[first].first, v[first].second, ax, ay) + dist(v[first].first, v[first].second, tx, ty);
        second = -1;
    } else {
        res = dist(v[second].first, v[second].second, bx, by) + dist(v[second].first, v[second].second, tx, ty);
        first = -1;
    }

    for (int i = 0; i < n; i++) {
        if (i == first || i == second)
            continue;

        res += 2 * dist(tx, ty, v[i].first, v[i].second);
    }

    cout << setprecision(10) << fixed << res << endl;
}


#include <iostream>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

double distance(double x1,double y1,double x2,double y2)
{
    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main()
{
    //ios_base::sync_with_stdio(false);

    double ax,ay,bx,by,tx,ty;
    cin>>ax>>ay>>bx>>by>>tx>>ty;

    int n;
    cin>>n;

    double cdist[n],D=0;
    pair<double,double> p[n];   //position of bottles
    for(int i=0;i<n;++i)
    {
        cin>>p[i].first>>p[i].second;
        cdist[i]=distance(tx,ty,p[i].first,p[i].second);
        D+=2*cdist[i];
    }

    set< pair<double,int> > A,B;
    double distA[n],distB[n];
    for(int i=0;i<n;++i)
    {
        double x=-cdist[i]+distance(ax,ay,p[i].first,p[i].second);
        distA[i]=x;
        A.insert({x,i});

        x=-cdist[i]+distance(bx,by,p[i].first,p[i].second);
        distB[i]=x;
        B.insert({x,i});
    }

    double temp1=D+A.begin()->first;
    double temp2=D+B.begin()->first;

    double temp3,res=D;
    set< pair<double,int> >::iterator it1,it2;
    for(auto it: A)
    {
        temp3=D;
        temp3+=it.first;
        int idx=it.second;
        B.erase({distB[idx],idx});
        if(not B.empty()) temp3+=B.begin()->first;
        res=min(res,temp3);
        B.insert({distB[idx],idx});
    }

    for(auto it: B)
    {
        temp3=D;
        temp3+=it.first;
        int idx=it.second;
        A.erase({distA[idx],idx});
        if(not A.empty()) temp3+=A.begin()->first;
        res=min(res,temp3);
        A.insert({distA[idx],idx});
    }

    double ans=min(min(temp1,temp2),res);

    cout.setf(ios::fixed);
    cout.precision(14);
    cout<<ans<<'\n';

    return 0;
}


#include <iostream>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

long double distance(long double x1,long double y1,long double x2,long double y2)
{
    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main()
{
    //ios_base::sync_with_stdio(false);

    long double ax,ay,bx,by,tx,ty;
    cin>>ax>>ay>>bx>>by>>tx>>ty;

    int n;
    cin>>n;

    long double cdist[n],D=0;
    pair<long double,long double> p[n];   //position of bottles
    for(int i=0;i<n;++i)
    {
        cin>>p[i].first>>p[i].second;
        cdist[i]=distance(tx,ty,p[i].first,p[i].second);
        D+=2*cdist[i];
    }

    set< pair<long double,int> > A,B;
    long double distA[n],distB[n];
    for(int i=0;i<n;++i)
    {
        long double x=-cdist[i]+distance(ax,ay,p[i].first,p[i].second);
        distA[i]=x;
        A.insert({x,i});

        x=-cdist[i]+distance(bx,by,p[i].first,p[i].second);
        distB[i]=x;
        B.insert({x,i});
    }

    long double temp1=D+A.begin()->first;
    long double temp2=D+B.begin()->first;

    long double temp3,res=D;
    for(auto it: A)
    {
        temp3=D;
        temp3+=it.first;
        int idx=it.second;
        B.erase({distB[idx],idx});
        if(not B.empty()) temp3+=B.begin()->first;
        res=min(res,temp3);
        B.insert({distB[idx],idx});
    }

    for(auto it: B)
    {
        temp3=D;
        temp3+=it.first;
        int idx=it.second;
        A.erase({distA[idx],idx});
        if(not A.empty()) temp3+=A.begin()->first;
        res=min(res,temp3);
        A.insert({distA[idx],idx});
    }

    long double ans=min(min(temp1,temp2),res);

    cout.setf(ios::fixed);
    cout.precision(14);
    cout<<ans<<'\n';

    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

#define FOR(a,b,step) for(int i=a;i<b;i+=step)
#define distance(x1,y1,x2,y2) sqrt(1.0*(x1-x2)*(x1-x2) + 1.0*(y1-y2)*(y1-y2))

pair<int,int> p[100100];
double cdist[100100],adist[100100],bdist[100100];   //cdist[]    distance from bin
double dp[2][2][100100];    //dp[Aflag][Bflag][n]
int n;

double f(int Aflag,int Bflag,int i)
{
    double &ret=dp[Aflag][Bflag][i];
    if(ret == ret) return ret;
    if(i == n) return Aflag||Bflag?0:1e16;

    double res=1e16;
    double temp1=2*cdist[i] + f(Aflag,Bflag,i+1);
    res=min(res,temp1);

    if(Aflag == 0)
    {
        double temp=adist[i]+cdist[i]+f(1,Bflag,i+1);
        res=min(res,temp);
    }

    if(Bflag == 0)
    {
        double temp=bdist[i]+cdist[i]+f(Aflag,1,i+1);
        res=min(res,temp);
    }

    return ret=res;
}

int main()
{
    int ax,ay,bx,by,tx,ty;
    scanf("%d%d%d%d%d%d",&ax,&ay,&bx,&by,&tx,&ty);

    scanf("%d",&n);
    FOR(0,n,1)
    {
        scanf("%d%d",&p[i].first,&p[i].second);
        cdist[i]=distance(tx,ty,p[i].first,p[i].second);
        adist[i]=distance(ax,ay,p[i].first,p[i].second);
        bdist[i]=distance(bx,by,p[i].first,p[i].second);
    }

    memset(dp,-1,sizeof(dp));

    printf("%0.12lf\n",f(0,0,0));

    return 0;
}


#include <iostream>
#include <set>
#include <cmath>
using namespace std;

double distance(double x1,double y1,double x2,double y2)
{
    return sqrt(pow(x2-x1,2)+pow(y2-y1,2));
}

int main()
{
    ios_base::sync_with_stdio(false);

    double ax,ay,bx,by,tx,ty;
    cin>>ax>>ay>>bx>>by>>tx>>ty;

    int n;
    cin>>n;

    double cdist[n],D=0;
    pair<double,int> p[n];
    for(int i=0;i<n;++i)
    {
        cin>>p[i].first>>p[i].second;
        cdist[i]=distance(tx,ty,p[i].first,p[i].second);
        D+=2*cdist[i];
    }

    set< pair<double,int> > A,B;
    double distA[n],distB[n];
    int flagA=0,flagB=0;
    for(int i=0;i<n;++i)
    {
        double x=-cdist[i]+distance(ax,ay,p[i].first,p[i].second);
        distA[i]=x;
        A.insert({x,i});

        x=-cdist[i]+distance(bx,by,p[i].first,p[i].second);
        distB[i]=x;
        B.insert({x,i});

    }

    double temp1=D+A.begin()->first;
    double temp2=D+A.begin()->first;

    double temp3=D;
    if(A.begin()->first < B.begin()->first)
    {
        temp3+=A.begin()->first;
        int idx=A.begin()->second;
        A.erase({distA[idx],idx});
        B.erase({distB[idx],idx});
        if(not B.empty()) temp3+=B.begin()->first;
    }

    else
    {
        temp3+=B.begin()->first;
        int idx=B.begin()->second;
        A.erase({distA[idx],idx});
        B.erase({distB[idx],idx});
        if(not A.empty()) temp3+=A.begin()->first;
    }

    double ans=min(min(temp1,temp2),temp3);

    cout.setf(ios::fixed);
    cout.precision(14);
    cout<<ans<<'\n';

    return 0;
}


#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
using namespace std;

double distance(double x1,double y1, double x2,double y2)
{
    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main()
{
    double ax,ay,bx,by,tx,ty;
    fscanf(stdin,"%lf%lf%lf%lf%lf%lf",&ax,&ay,&bx,&by,&tx,&ty);

    int n;
    fscanf(stdin,"%d",&n);

    double cdist[n],D=0;
    pair<double,double> p[n];   //position of bottles
    for(int i=0;i<n;++i)
    {
        fscanf(stdin,"%lf%lf",&p[i].first,&p[i].second);
        cdist[i]=distance(tx,ty,p[i].first,p[i].second);
        D+=2*cdist[i];
    }

    set< pair<double,int> > A,B;
    double distA[n],distB[n];
    for(int i=0;i<n;++i)
    {
        double x=-cdist[i]+distance(ax,ay,p[i].first,p[i].second);
        distA[i]=x;
        A.insert({x,i});

        x=-cdist[i]+distance(bx,by,p[i].first,p[i].second);
        distB[i]=x;
        B.insert({x,i});
    }

    double temp1=D+A.begin()->first;    //only A moves
    double temp2=D+B.begin()->first;    //only B moves

    double temp3=D+A.begin()->first;    //A moves first
    int idx=A.begin()->second;
    B.erase({distB[idx],idx});
    if(not B.empty()) temp3+=B.begin()->first;
    B.insert({distB[idx],idx});

    double temp4=D+B.begin()->first;    //B moves first
    idx=B.begin()->second;
    A.erase({distA[idx],idx});
    if(not A.empty()) temp4+=A.begin()->first;
//     A.insert({distA[idx],idx});

    double ans=min(min(temp1,temp2),min(temp3,temp4));

    fprintf(stdout,"%lf\n",ans);

    return 0;
}