#include <algorithm>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>

using namespace std;

const int MAXN = 2010;

struct Pen{
    int p;
    int id;
}pen[MAXN];
struct Sto{
    int p;
    int id;
}sto[MAXN];

bool comp1(Pen p1, Pen p2){
    return p1.p < p2.p;
}
bool comp2(Sto s1, Sto s2){
    return s1.p > s2.p;
}

vector<int>v[MAXN];

int in[MAXN];
bool has[MAXN];

int main(){
    int n, k;
    while (scanf("%d%d", &n, &k) != EOF){
        for (int i = 0; i <= k; i++){
            v[i].clear();
        }
        int p, id, pnum = 0, snum = 0;
        memset(has, false, sizeof(has));
        for (int i = 0; i < n; i++){
            scanf("%d%d", &in[i], &id);
            if (id == 1){
                sto[snum].p = in[i];
                sto[snum++].id = i + 1;
            }
            if (id == 2){
                pen[pnum].p = in[i];
                pen[pnum++].id = i + 1;
            }
        }
        sort(pen, pen + pnum, comp1);
        sort(sto, sto + snum, comp2);
        int i;
        for (i = 0; i < k && i < snum; i++){
            v[i].push_back(sto[i].id);
            has[i] = true;
        }
        if (i < snum){
            for (; i < snum; i++){
                v[k - 1].push_back(sto[i].id);
            }
            for (int j = 0; j < pnum; j++){
                v[k - 1].push_back(pen[j].id);
            }
        }else{
            int j;
            for (j = 0; i < k && j < pnum; i++, j++){
                v[i].push_back(pen[j].id);
            }
            for (; j < pnum; j++){
                v[k - 1].push_back(pen[j].id);
            }
        }
        double ans = 0;
        for (int i = 0; i < k; i++){
            double sum = 0;
            int MIN = 1000000010;
            int size = v[i].size();
            for (int j= 0; j < size; j++){
                sum += in[v[i][j] - 1];
                if (MIN > in[v[i][j] - 1]){
                    MIN = in[v[i][j] - 1];
                }
            }
            if (has[i]){
                sum = sum - MIN * 0.5;
            }
            ans += sum;
        }
        printf("%.1lf\n", ans);
        for (int i = 0; i < k; i++){
            int size = v[i].size();
            cout << size << " ";
            for (int j = 0; j < size - 1; j++){
                cout << v[i][j] << " ";
            }
            cout << v[i][size - 1] << endl;
        }
    }
   return 0;
}


#include <algorithm>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>

using namespace std;

const int MAXN = 1010;

struct Pen{
    int p;
    int id;
}pen[MAXN];
struct Sto{
    int p;
    int id;
}sto[MAXN];

bool comp1(Pen p1, Pen p2){
    return p1.p < p2.p;
}
bool comp2(Sto s1, Sto s2){
    return s1.p < s2.p;
}

vector<int>v[MAXN];

int in[MAXN];
bool has[MAXN];

int main(){
    int n, k;
    while (scanf("%d%d", &n, &k) != EOF){
        int p, id, pnum = 0, snum = 0;
        memset(has, false, sizeof(has));
        for (int i = 0; i < n; i++){
            scanf("%d%d", &in[i], &id);
            if (id == 1){
                sto[snum].p = in[i];
                sto[snum++].id = i + 1;
            }
            if (id == 2){
                pen[pnum].p = in[i];
                pen[pnum++].id = i + 1;
            }
        }
        sort(pen, pen + pnum, comp1);
        sort(sto, sto + snum, comp2);
        int i;
        for (i = 0; i < k && i < snum; i++){
            v[i].push_back(sto[i].id);
            has[i] = true;
        }
        if (i < snum){
            for (; i < snum; i++){
                v[0].push_back(sto[i].id);
            }
            for (int j = 0; j < pnum; j++){
                v[0].push_back(pen[j].id);
            }
        }else{
            int j;
            for (j = 0; i < k && j < pnum; i++, j++){
                v[i].push_back(pen[j].id);
            }
            for (; j < pnum; j++){
                v[k - 1].push_back(pen[j].id);
            }
        }
        double ans = 0;
        for (int i = 0; i < k; i++){
            double sum = 0;
            int MIN = 1000000010;
            int size = v[i].size();
            for (int j= 0; j < size; j++){
                sum += in[v[i][j] - 1];
                if (MIN > in[v[i][j] - 1]){
                    MIN = in[v[i][j] - 1];
                }
            }
            if (has[i]){
                sum = sum - MIN * 0.5;
            }
            ans += sum;
        }
        cout << ans << endl;
        for (int i = 0; i < k; i++){
            int size = v[i].size();
            cout << size << " ";
            for (int j = 0; j < size; j++){
                cout << v[i][j] << " ";
            }
            cout << endl;
        }
    }
   return 0;
}


#include <algorithm>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>

using namespace std;

const int MAXN = 1010;

struct Pen{
    int p;
    int id;
}pen[MAXN];
struct Sto{
    int p;
    int id;
}sto[MAXN];

bool comp1(Pen p1, Pen p2){
    return p1.p < p2.p;
}
bool comp2(Sto s1, Sto s2){
    return s1.p < s2.p;
}

vector<int>v[MAXN];

int in[MAXN];
bool has[MAXN];

int main(){
    int n, k;
    while (scanf("%d%d", &n, &k) != EOF){
        for (int i = 0; i <= k; i++){
            v[i].clear();
        }
        int p, id, pnum = 0, snum = 0;
        memset(has, false, sizeof(has));
        for (int i = 0; i < n; i++){
            scanf("%d%d", &in[i], &id);
            if (id == 1){
                sto[snum].p = in[i];
                sto[snum++].id = i + 1;
            }
            if (id == 2){
                pen[pnum].p = in[i];
                pen[pnum++].id = i + 1;
            }
        }
        sort(pen, pen + pnum, comp1);
        sort(sto, sto + snum, comp2);
        int i;
        for (i = 0; i < k && i < snum; i++){
            v[i].push_back(sto[i].id);
            has[i] = true;
        }
        if (i < snum){
            for (; i < snum; i++){
                v[0].push_back(sto[i].id);
            }
            for (int j = 0; j < pnum; j++){
                v[0].push_back(pen[j].id);
            }
        }else{
            int j;
            for (j = 0; i < k && j < pnum; i++, j++){
                v[i].push_back(pen[j].id);
            }
            for (; j < pnum; j++){
                v[k - 1].push_back(pen[j].id);
            }
        }
        double ans = 0;
        for (int i = 0; i < k; i++){
            double sum = 0;
            int MIN = 1000000010;
            int size = v[i].size();
            for (int j= 0; j < size; j++){
                sum += in[v[i][j] - 1];
                if (MIN > in[v[i][j] - 1]){
                    MIN = in[v[i][j] - 1];
                }
            }
            if (has[i]){
                sum = sum - MIN * 0.5;
            }
            ans += sum;
        }
        printf("%.1lf\n", ans);
        for (int i = 0; i < k; i++){
            int size = v[i].size();
            cout << size << " ";
            for (int j = 0; j < size; j++){
                cout << v[i][j] << " ";
            }
            cout << endl;
        }
    }
   return 0;
}


#define ReadFromConsole 1
#define inFile "input.txt"
#define outFile "output.txt"

#include <iostream>
#include <fstream>
#include <conio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <ctype.h>
#include <map>
#include <set>

using namespace std;

#define SET(a,x) memset((a),(x),sizeof(a))

typedef vector< int > vi;
typedef vector< vi > vii;
typedef vector< vii > viii;
typedef vector< int >:: iterator viit;

typedef long long int ll;
typedef unsigned int ui;

pair< int ,int> tab[2000], kar[2000];
int tc, kc;
set<pair<int,int>> ans[2000];

int main()
{
    if( fopen("debug.file.txt", "r") == NULL ) {
        if( !ReadFromConsole )
        {
            freopen(inFile,"r",stdin);
            freopen(outFile,"w",stdout);
        }
    }
    else {
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    }

    int n,k;
    cin >> n>>k;
    tc = kc = 0;
    ll aaa=0;
    for( int i=0; i<n; i++ )
    {
        int c,t;
        cin >>c>>t;
        aaa += c;
        if( t == 1 )
        {
            tab[tc++] = make_pair(c,i+1);
        }
        else
            kar[kc++] = make_pair(c,i+1);
    }
    sort( tab, tab + tc);
    reverse(tab, tab + tc);
    sort( kar, kar + kc);
    reverse(kar, kar+kc);

    int sz=0;
    int mi=0;
    int i;
    for( i=0; i<tc && i<k; i++)
    {
        ans[i].insert( tab[i] );
    }
    if( i <tc )
    {
        while ( i<tc )
            ans[k-1].insert( tab[i++] );

        for( int j=0; i<kc; j++)
            ans[k-1].insert( kar[j] );
    }
    else
    {
        int j;
        for( j=0; i<k; j++, i++ )
            ans[i].insert( kar[j]);
        if( j<kc )
            while( j<kc )
                ans[k-1].insert( kar[j++] );
    }

    for( int i=0;i< min(k,tc); i++)
        mi += ans[i].begin()->first;

    printf("%.1f\n", aaa - (float)mi/2);

    int ind = 0;
    for( int i=0; i<k; i++)
    {
        cout << ans[i].size() << " ";
        for( set<pair<int,int>>::iterator it=ans[i].begin(); it!=ans[i].end(); it++)
            cout << it->second << " ";
        cout << endl;
    }

    return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define N 100000
typedef double dd;
typedef long long ll;

dd dist(ll a,ll b,ll x,ll y)
{
	return dd(sqrt(pow((a-x),2) + pow((b-y),2)));
}

int main()
{
	ll ax,ay,bx,by,tx,ty;
	dd total,botd;
	int i,n,j,k;
	vector <dd> arr;
	cin>>ax>>ay>>bx>>by>>tx>>ty>>n;
	for(i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		botd = dist(tx,ty,x,y);
		total += botd;
		arr.push_back(min(dist(ax,ay,x,y)-botd,dist(bx,by,x,y)-botd));
	}
	sort(arr.begin(),arr.end());
	total *= 2;
	cout<<setprecision(15)<<min(total+arr[0],total+arr[0]+arr[1])<<endl;
	//printf("%.12lf\n",min(total+arr[0],total+arr[0]+arr[1]));
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define N 100000
#define mp make_pair
#define s second
#define f first
typedef double dd;
typedef long long ll;

dd dist(ll a,ll b,ll x,ll y)
{
	return dd(sqrt(pow((a-x),2) + pow((b-y),2)));
}

int main()
{
	ll ax,ay,bx,by,tx,ty;
	dd total,botd;
	int i,n,j,k;
	vector<pair<int,dd> > arr1,arr2;
	cin>>ax>>ay>>bx>>by>>tx>>ty>>n;
	for(i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		botd = dist(tx,ty,x,y);
		total += botd*2;
		arr1.push_back(mp(i,dist(ax,ay,x,y)-botd));
		arr2.push_back(mp(i,dist(bx,by,x,y)-botd));
	}
	sort(arr1.begin(),arr1.end(),[](const pair<int, double>& lhs, const pair<int, double>& rhs) {
			             return lhs.second < rhs.second; });
	sort(arr2.begin(),arr2.end(),[](const pair<int, double>& lhs, const pair<int, double>& rhs) {
			             return lhs.second < rhs.second; });
	for(i=0;i<arr1.size();i++)
	cout<<arr1[i].f<<"**"<<arr1[i].s<<endl;
	for(i=0;i<arr2.size();i++)
	cout<<arr2[i].f<<"**"<<arr2[i].s<<endl;
	if(arr1[0].f != arr2[0].f)
	{
		//cout<<"HERE\n";
		cout<<setprecision(15)<<min(total+arr2[0].s,min(total+arr1[0].s+arr2[0].s,total+arr1[0].s))<<endl;
	}
	else
	{
		if(arr1[0].s < arr2[0].s)
			cout<<setprecision(15)<<min(total+arr1[0].s,min(total+arr2[0].s,min(total+arr1[0].s+arr2[1].s,total+arr1[1].s+arr2[0].s)))<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define N 100000
typedef double dd;

dd dist(dd a,dd b,dd x,dd y)
{
	return sqrt(pow((a-x),2) + pow((b-y),2));
}

int main()
{
	dd ax,ay,bx,by,tx,ty,total;
	int i,n,j,k;
	dd bot[N][2];
	vector <dd> arr1,arr2;
	cin>>ax>>ay>>bx>>by>>tx>>ty>>n;
	for(i=0;i<n;i++)
	{
		cin>>bot[i][0]>>bot[i][1];
		total += dist(tx,ty,bot[i][0],bot[i][1]);
		arr1.push_back(dist(ax,ay,bot[i][0],bot[i][1]) - dist(tx,ty,bot[i][0],bot[i][1]));
		arr2.push_back(dist(bx,by,bot[i][0],bot[i][1]) - dist(tx,ty,bot[i][0],bot[i][1]));
	}
	sort(arr1.begin(),arr1.end());
	sort(arr2.begin(),arr2.end());
	total *= 2;
	if(arr1[0] < arr2[0])
	{
		//cout<<arr1[0]<<endl;
		if(arr2[0] < 0)
			cout<<total+arr1[0]+arr2[0]<<endl;
		else
			cout<<total+arr1[0]<<endl;

	}
	else
	{
		//cout<<arr2[0]<<endl;
		if(arr1[0] < 0)
			cout<<total+arr1[0]+arr2[0]<<endl;
		else
			cout<<total+arr2[0]<<endl;
	}

	//for(i=0;i<arr.size();i++)
	//	cout<<arr[i]<<endl;
	//cout<<total+arr[0]+arr[1]+arr[2]<<endl;
	//cout<<dist(ax,ay,bx,by)<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define N 100000
#define mp make_pair
#define s second
#define f first
typedef double dd;
typedef long long ll;

dd dist(ll a,ll b,ll x,ll y)
{
	return dd(sqrt(pow((a-x),2) + pow((b-y),2)));
}

int main()
{
	ll ax,ay,bx,by,tx,ty;
	dd total,botd;
	int i,n,j,k;
	vector<pair<int,dd> > arr1,arr2;
	cin>>ax>>ay>>bx>>by>>tx>>ty>>n;
	for(i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		botd = dist(tx,ty,x,y);
		total += botd*2;
		arr1.push_back(mp(i,dist(ax,ay,x,y)-botd));
		arr2.push_back(mp(i,dist(bx,by,x,y)-botd));
	}
	sort(arr1.begin(),arr1.end(),[](const pair<int, double>& lhs, const pair<int, double>& rhs) {
			             return lhs.second < rhs.second; });
	sort(arr2.begin(),arr2.end(),[](const pair<int, double>& lhs, const pair<int, double>& rhs) {
			             return lhs.second < rhs.second; });
	/*for(i=0;i<arr1.size();i++)
	cout<<arr1[i].f<<"**"<<arr1[i].s<<endl;
	for(i=0;i<arr2.size();i++)
	cout<<arr2[i].f<<"**"<<arr2[i].s<<endl;*/
	if(arr1[0].f != arr2[0].f)
	{
		//cout<<"HERE\n";
		cout<<setprecision(15)<<min(total+arr2[0].s,min(total+arr1[0].s+arr2[0].s,total+arr1[0].s))<<endl;
	}
	else
	{
		if(arr1[0].s < arr2[0].s)
			cout<<setprecision(15)<<min(total+arr2[1].s,min(total+arr1[0].s+arr2[1].s,total+arr1[0].s))<<endl;
		else
		{
			//cout<<arr1[1].s<<endl;
			cout<<setprecision(15)<<min(total+arr2[0].s,min(total+arr1[1].s+arr2[0].s,total+arr1[1].s))<<endl;
		}
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define N 100000
#define mp make_pair
#define s second
#define f first
typedef double dd;
typedef long long ll;

dd dist(ll a,ll b,ll x,ll y)
{
	return dd(sqrt(pow((a-x),2) + pow((b-y),2)));
}

int main()
{
	ll ax,ay,bx,by,tx,ty;
	dd total,botd;
	int i,n,j,k;
	vector<pair<int,dd> > arr1,arr2;
	cin>>ax>>ay>>bx>>by>>tx>>ty>>n;
	for(i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		botd = dist(tx,ty,x,y);
		total += botd*2;
		arr1.push_back(mp(i,dist(ax,ay,x,y)-botd));
		arr2.push_back(mp(i,dist(bx,by,x,y)-botd));
	}
	sort(arr1.begin(),arr1.end(),[](const pair<int, double>& lhs, const pair<int, double>& rhs) {
			             return lhs.second < rhs.second; });
	sort(arr2.begin(),arr2.end(),[](const pair<int, double>& lhs, const pair<int, double>& rhs) {
			             return lhs.second < rhs.second; });
	if(arr1[0].f != arr2[0].f)
		cout<<setprecision(15)<<min(total+arr2[0].s,min(total+arr1[0].s+arr2[0].s,total+arr1[0].s))<<endl;
	else
		cout<<setprecision(15)<<min(total+arr1[0].s,min(total+arr2[0].s,min(total+arr1[0].s+arr2[1].s,total+arr1[1].s+arr2[0].s)))<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define N 100000
#define mp make_pair
#define s second
#define f first
typedef double dd;
typedef long long ll;

dd dist(ll a,ll b,ll x,ll y)
{
	return dd(sqrt(pow((a-x),2) + pow((b-y),2)));
}

int main()
{
	ll ax,ay,bx,by,tx,ty;
	dd total,botd;
	int i,n,j,k;
	vector<pair<int,dd> > arr1,arr2;
	cin>>ax>>ay>>bx>>by>>tx>>ty>>n;
	for(i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		botd = dist(tx,ty,x,y);
		total += botd*2;
		arr1.push_back(mp(i,dist(ax,ay,x,y)-botd));
		arr2.push_back(mp(i,dist(bx,by,x,y)-botd));
	}
	sort(arr1.begin(),arr1.end(),[](const pair<int, double>& lhs, const pair<int, double>& rhs) {
			             return lhs.second < rhs.second; });
	sort(arr2.begin(),arr2.end(),[](const pair<int, double>& lhs, const pair<int, double>& rhs) {
			             return lhs.second < rhs.second; });
	/*for(i=0;i<arr1.size();i++)
	cout<<arr1[i].f<<"**"<<arr1[i].s<<endl;
	for(i=0;i<arr2.size();i++)
	cout<<arr2[i].f<<"**"<<arr2[i].s<<endl;*/
	if(arr1[0].f != arr2[0].f)
	{
		//cout<<"HERE\n";
		cout<<setprecision(15)<<min(total+arr2[0].s,min(total+arr1[0].s+arr2[0].s,total+arr1[0].s))<<endl;
	}
	else
	{
		if(arr1[0].s < arr2[0].s)
			cout<<setprecision(15)<<min(total+arr1[0].s,min(total+arr2[0].s,min(total+arr1[0].s+arr2[1].s,total+arr1[1].s+arr2[0].s)))<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define N 100000
typedef double dd;

dd dist(dd a,dd b,dd x,dd y)
{
	return sqrt(pow((a-x),2) + pow((b-y),2));
}

int main()
{
	dd ax,ay,bx,by,tx,ty,total,botd;
	int i,n,j,k;
	vector <dd> arr;
	cin>>ax>>ay>>bx>>by>>tx>>ty>>n;
	for(i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		botd = dist(tx,ty,x,y);
		total += botd;
		arr.push_back(min(dist(ax,ay,x,y)-botd,dist(bx,by,x,y)-botd));
	}
	sort(arr.begin(),arr.end());
	total *= 2;
	printf("%.12lf\n",min(total+arr[0],total+arr[0]+arr[1]));
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define N 100000
#define mp make_pair
#define s second
#define f first
typedef double dd;
typedef long long ll;

dd dist(ll a,ll b,ll x,ll y)
{
	return dd(sqrt(pow((a-x),2) + pow((b-y),2)));
}

int main()
{
	ll ax,ay,bx,by,tx,ty;
	dd total,botd;
	int i,n,j,k;
	vector<pair<int,dd> > arr1,arr2;
	cin>>ax>>ay>>bx>>by>>tx>>ty>>n;
	for(i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		botd = dist(tx,ty,x,y);
		total += botd*2;
		arr1.push_back(mp(i,dist(ax,ay,x,y)-botd));
		arr2.push_back(mp(i,dist(bx,by,x,y)-botd));
	}
	sort(arr1.begin(),arr1.end(),[](const pair<int, double>& lhs, const pair<int, double>& rhs) {
			             return lhs.second < rhs.second; });
	sort(arr2.begin(),arr2.end(),[](const pair<int, double>& lhs, const pair<int, double>& rhs) {
			             return lhs.second < rhs.second; });
	if(arr1[0].f != arr2[0].f)
		cout<<setprecision(15)<<min(total+arr2[0].s,min(total+arr1[0].s+arr2[0].s,total+arr1[0].s))<<endl;
	else
	//cout<<setprecision(15)<<min(total+arr1[0].s,min(total+arr2[0].s,min(total+arr1[0].s+arr2[1].s,total+arr1[1].s+arr2[0].s)))<<endl;
		cout<<setprecision(15)<<min(total+arr2[0].s,min(total+arr1[0].s+arr2[1].s,total+arr1[1].s+arr2[0].s))<<endl;
	return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 5;
const ll INF = 5e18;

ll x[N];
ll y[N];
ll ax, ay, bx, by, tx, ty;
int n;

ld calc(int an, int bn)
{
    if(an == bn) return INF;
    ld res = 0;
    for(int i = 0; i < n; i++)
    {
        if(i == an)
        {
            res += sqrt((ld)((x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else if (i == bn)
        {
            res += sqrt((ld)((x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else
        {
            res += 2 * sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> ax >> ay >> bx >> by >> tx >> ty;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    // n == 1
    int anmin1 = -1, anmin2 = -1, bnmin1 = -1, bnmin2 = -1;
    ll ammin1 = INF, ammin2 = INF, bmmin1 = INF, bmmin2 = INF;
    for(int i = 0; i < n; i++)
    {
        ld tdist = sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        ld adist = sqrt((ld)((x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay))) - tdist;
        if(adist < ammin1)
        {
            ammin2 = ammin1;
            anmin2 = anmin1;
            ammin1 = adist;
            anmin1 = i;
        }
        else if(adist < ammin2)
        {
            ammin2 = adist;
            anmin2 = i;
        }
        ll bdist = sqrt((ld)((x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by))) - tdist;
        if(bdist < bmmin1)
        {
            bmmin2 = bmmin1;
            bnmin2 = bnmin1;
            bmmin1 = bdist;
            bnmin1 = i;
        }
        else if(bdist < bmmin2)
        {
            bmmin2 = bdist;
            bnmin2 = i;
        }
    }
    cout.precision(20);
    if(n == 1)
    {
        cout << sqrt((ld)min(ammin1, bmmin1));
        return 0;
    }
    ld res = min(calc(anmin1, -1), calc(-1, bnmin1));
    res = min(res, calc(anmin1, bnmin1));
    res = min(res, calc(anmin2, bnmin1));
    res = min(res, calc(anmin1, bnmin2));
    res = min(res, calc(anmin2, bnmin2));
    cout << res;
    return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 5;
const ll INF = 5e18;

ll x[N];
ll y[N];
ll ax, ay, bx, by, tx, ty;
int n;

ld calc(int an, int bn)
{
    if(an == bn) return INF;
    ld res = 0;
    for(int i = 0; i < n; i++)
    {
        if(i == an)
        {
            res += sqrt((ld)((x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else if (i == bn)
        {
            res += sqrt((ld)((x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else
        {
            res += 2 * sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> ax >> ay >> bx >> by >> tx >> ty;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    // n == 1
    int anmin1 = -1, anmin2 = -1, bnmin1 = -1, bnmin2 = -1;
    ll ammin1 = INF, ammin2 = INF, bmmin1 = INF, bmmin2 = INF;
    for(int i = 0; i < n; i++)
    {
        ld tdist = sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        ld adist = sqrt((ld)((x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay))) - tdist;
        if(adist < ammin1)
        {
            ammin2 = ammin1;
            anmin2 = anmin1;
            ammin1 = adist;
            anmin1 = i;
        }
        else if(adist < ammin2)
        {
            ammin2 = adist;
            anmin2 = i;
        }
        ld bdist = sqrt((ld)((x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by))) - tdist;
        if(bdist < bmmin1)
        {
            bmmin2 = bmmin1;
            bnmin2 = bnmin1;
            bmmin1 = bdist;
            bnmin1 = i;
        }
        else if(bdist < bmmin2)
        {
            bmmin2 = bdist;
            bnmin2 = i;
        }
    }
    cout.precision(20);
    if(n == 1)
    {
        ld tdist = sqrt((ld)((x[0] - tx) * (x[0] - tx) + (y[0] - ty) * (y[0] - ty)));
        ld adist = sqrt((ld)((x[0] - ax) * (x[0] - ax) + (y[0] - ay) * (y[0] - ay)));
        ld bdist = sqrt((ld)((x[0] - bx) * (x[0] - bx) + (y[0] - by) * (y[0] - by)));
        cout << tdist + min(adist, bdist);
        return 0;
    }
    ld res = min(calc(anmin1, -1), calc(-1, bnmin1));
    res = min(res, calc(anmin1, bnmin1));
    res = min(res, calc(anmin2, bnmin1));
    res = min(res, calc(anmin1, bnmin2));
    res = min(res, calc(anmin2, bnmin2));
    cout << res;
    return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 5;
const ll INF = 5e18;

ll x[N];
ll y[N];
ll ax, ay, bx, by, tx, ty;
int n;

ld calc(int an, int bn)
{
    if(an == bn) return INF;
    ld res = 0;
    for(int i = 0; i < n; i++)
    {
        if(i == an)
        {
            res += sqrt((ld)((x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else if (i == bn)
        {
            res += sqrt((ld)((x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else
        {
            res += 2 * sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> ax >> ay >> bx >> by >> tx >> ty;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    // n == 1
    int anmin1 = -1, anmin2 = -1, bnmin1 = -1, bnmin2 = -1;
    ll ammin1 = INF, ammin2 = INF, bmmin1 = INF, bmmin2 = INF;
    for(int i = 0; i < n; i++)
    {
        ll tdist = (x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty);
        ll adist = (x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay) - tdist;
        if(adist < ammin1)
        {
            ammin2 = ammin1;
            anmin2 = anmin1;
            ammin1 = adist;
            anmin1 = i;
        }
        else if(adist < ammin2)
        {
            ammin2 = adist;
            anmin2 = i;
        }
        ll bdist = (x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by) - tdist;
        if(bdist < bmmin1)
        {
            bmmin2 = bmmin1;
            bnmin2 = bnmin1;
            bmmin1 = bdist;
            bnmin1 = i;
        }
        else if(bdist < bmmin2)
        {
            bmmin2 = bdist;
            bnmin2 = i;
        }
    }
    cout.precision(20);
    if(n == 1)
    {
        cout << sqrt((ld)min(ammin1, bmmin1));
        return 0;
    }
    ld res = min(calc(anmin1, -1), calc(-1, bnmin1));
    res = min(res, calc(anmin1, bnmin1));
    res = min(res, calc(anmin2, bnmin1));
    res = min(res, calc(anmin1, bnmin2));
    res = min(res, calc(anmin2, bnmin2));
    cout << res;
    return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 5;
const ll INF = 5e18;

ll x[N];
ll y[N];
ll ax, ay, bx, by, tx, ty;
int n;

ld calc(int an, int bn)
{
    if(an == bn) return INF;
    ld res = 0;
    for(int i = 0; i < n; i++)
    {
        if(i == an)
        {
            res += sqrt((ld)((x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else if (i == bn)
        {
            res += sqrt((ld)((x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else
        {
            res += 2 * sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> ax >> ay >> bx >> by >> tx >> ty;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    // n == 1
    int anmin1 = -1, anmin2 = -1, bnmin1 = -1, bnmin2 = -1;
    ld ammin1 = INF, ammin2 = INF, bmmin1 = INF, bmmin2 = INF;
    for(int i = 0; i < n; i++)
    {
        ld tdist = sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        ld adist = sqrt((ld)((x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay))) - tdist;
        if(adist < ammin1)
        {
            ammin2 = ammin1;
            anmin2 = anmin1;
            ammin1 = adist;
            anmin1 = i;
        }
        else if(adist < ammin2)
        {
            ammin2 = adist;
            anmin2 = i;
        }
        ld bdist = sqrt((ld)((x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by))) - tdist;
        if(bdist < bmmin1)
        {
            bmmin2 = bmmin1;
            bnmin2 = bnmin1;
            bmmin1 = bdist;
            bnmin1 = i;
        }
        else if(bdist < bmmin2)
        {
            bmmin2 = bdist;
            bnmin2 = i;
        }
    }
    cout.precision(20);
    if(n == 1)
    {
        ld tdist = sqrt((ld)((x[0] - tx) * (x[0] - tx) + (y[0] - ty) * (y[0] - ty)));
        ld adist = sqrt((ld)((x[0] - ax) * (x[0] - ax) + (y[0] - ay) * (y[0] - ay)));
        ld bdist = sqrt((ld)((x[0] - bx) * (x[0] - bx) + (y[0] - by) * (y[0] - by)));
        cout << tdist + min(adist, bdist);
        return 0;
    }
    ld res = min(calc(anmin1, -1), calc(-1, bnmin1));
    res = min(res, calc(anmin1, bnmin1));
    res = min(res, calc(anmin2, bnmin1));
    res = min(res, calc(anmin1, bnmin2));
    res = min(res, calc(anmin2, bnmin2));
    cout << res;
    return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 5;
const ll INF = 5e18;

ll x[N];
ll y[N];
ll ax, ay, bx, by, tx, ty;
int n;

ld calc(int an, int bn)
{
    ld res = 0;
    for(int i = 0; i < n; i++)
    {
        if(i == an)
        {
            res += sqrt((ld)((x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else if (i == bn)
        {
            res += sqrt((ld)((x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else
        {
            res += 2 * sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> ax >> ay >> bx >> by >> tx >> ty;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    // n == 1
    int anmin1 = -1, anmin2 = -1, bnmin1 = -1, bnmin2 = -1;
    ll ammin1 = INF, ammin2 = INF, bmmin1 = INF, bmmin2 = INF;
    for(int i = 0; i < n; i++)
    {
        ll tdist = (x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty);
        ll adist = (x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay) - tdist;
        if(adist < ammin1)
        {
            ammin2 = ammin1;
            anmin2 = anmin1;
            ammin1 = adist;
            anmin1 = i;
        }
        else if(adist < ammin2)
        {
            ammin2 = adist;
            anmin2 = i;
        }
        ll bdist = (x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by) - tdist;
        if(bdist < bmmin1)
        {
            bmmin2 = bmmin1;
            bnmin2 = bnmin1;
            bmmin1 = bdist;
            bnmin1 = i;
        }
        else if(bdist < bmmin2)
        {
            bmmin2 = bdist;
            bnmin2 = i;
        }
    }
    cout.precision(20);
    if(n == 1)
    {
        cout << sqrt((ld)min(ammin1, bmmin1));
        return 0;
    }
    ld res = min(calc(anmin1, -1), calc(-1, bnmin1));
    if(anmin1 != bnmin1)
    {
        cout << min(res, calc(anmin1, bnmin1));
    }
    else if(ammin1 + bmmin2 < ammin2 + bmmin1)
    {
        cout << min(res, calc(anmin1, bnmin2));
    }
    else
    {
        cout << min(res, calc(anmin2, bnmin1));
    }
    return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 5;
const ll INF = 5e18;

ll x[N];
ll y[N];
ll ax, ay, bx, by, tx, ty;
int n;

ld calc(int an, int bn)
{
    ld res = 0;
    for(int i = 0; i < n; i++)
    {
        if(i == an)
        {
            res += sqrt((ld)((x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else if (i == bn)
        {
            res += sqrt((ld)((x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by)));
            res += sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
        else
        {
            res += 2 * sqrt((ld)((x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty)));
        }
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> ax >> ay >> bx >> by >> tx >> ty;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    // n == 1
    int anmin1 = -1, anmin2 = -1, bnmin1 = -1, bnmin2 = -1;
    ll ammin1 = INF, ammin2 = INF, bmmin1 = INF, bmmin2 = INF;
    for(int i = 0; i < n; i++)
    {
        ll tdist = (x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty);
        ll adist = (x[i] - ax) * (x[i] - ax) + (y[i] - ay) * (y[i] - ay) - tdist;
        if(adist < ammin1)
        {
            ammin2 = ammin1;
            anmin2 = anmin1;
            ammin1 = adist;
            anmin1 = i;
        }
        else if(adist < ammin2)
        {
            ammin2 = adist;
            anmin2 = i;
        }
        ll bdist = (x[i] - bx) * (x[i] - bx) + (y[i] - by) * (y[i] - by) - tdist;
        if(bdist < bmmin1)
        {
            bmmin2 = bmmin1;
            bnmin2 = bnmin1;
            bmmin1 = bdist;
            bnmin1 = i;
        }
        else if(bdist < bmmin2)
        {
            bmmin2 = bdist;
            bnmin2 = i;
        }
    }
    cout.precision(20);
    if(n == 1)
    {
        cout << sqrt((ld)min(ammin1, bmmin1));
        return 0;
    }
    if(anmin1 != bnmin1)
    {
        cout << calc(anmin1, bnmin1);
    }
    else if(ammin1 + bmmin2 < ammin2 + bmmin1)
    {
        cout << calc(anmin1, bnmin2);
    }
    else
    {
        cout << calc(anmin2, bnmin1);
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll mod=1e18;
int poww(int a,int b,int mod){
    int res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

/*ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}*/
/*ll add(ll a,ll b){
    ll ret=1ll*(a%mod)+1ll*(b%mod);
    ret%=mod;
    if(ret<0) ret+=mod;
    R ret;
}
*/
/*ll mul(ll a,ll b){
    ll ret=1ll*(a%mod)*(b%mod);
    ret%=mod;
    R ret;
}
*/
void min_self(ll& x,ll y){
x=min(x,y);
}

struct point{
ll x,y;
};

point a[200200];
pair<double,ll> b[200200],c[200200];
ll n;

double dis(point a,point b){
R sqrt( (b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y) );
}

bool cmp(pair<double,ll> a1,pair<double,ll> a2){
    R (a1.F<a2.F);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    point p1,p2,p0;
    cin>>p1.x>>p1.y>>p2.x>>p2.y>>p0.x>>p0.y;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].x>>a[i].y;
    }
    for(int i=0;i<n;i++){
        b[i].F=dis(p1,a[i])-dis(p0,a[i]);
        c[i].F=dis(p2,a[i])-dis(p0,a[i]);
        b[i].S=i;
        c[i].S=i;
    }
    sort(b,b+n,cmp);
    sort(c,c+n,cmp);

    double Ans=0;
    ll po1=b[0].S;
    ll po2=c[0].S;
    Ans+=b[0].F+c[0].F;
    if(po2==po1){
        Ans=min(b[0].F+c[1].F,b[1].F+c[0].F);
    }

    //cout<<po1<<" "<<po2<<" ";

    for(int i=0;i<n;i++){
        Ans+=2*dis(p0,a[i]);
    }
    cout<<fixed<<setprecision(12)<<Ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll mod=1e18;
int poww(int a,int b,int mod){
    int res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

/*ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}*/
/*ll add(ll a,ll b){
    ll ret=1ll*(a%mod)+1ll*(b%mod);
    ret%=mod;
    if(ret<0) ret+=mod;
    R ret;
}
*/
/*ll mul(ll a,ll b){
    ll ret=1ll*(a%mod)*(b%mod);
    ret%=mod;
    R ret;
}
*/
void min_self(ll& x,ll y){
x=min(x,y);
}

struct point{
ll x,y;
};

point a[200200];
pair<double,ll> b[200200],c[200200];
ll n;

double dis(point a,point b){
R sqrt( (b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y) );
}

bool cmp(pair<double,ll> a1,pair<double,ll> a2){
    R (a1.F<a2.F);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    point p1,p2,p0;
    cin>>p1.x>>p1.y>>p2.x>>p2.y>>p0.x>>p0.y;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].x>>a[i].y;
    }
    for(int i=0;i<n;i++){
        b[i].F=dis(p1,a[i])-dis(p0,a[i]);
        c[i].F=dis(p2,a[i])-dis(p0,a[i]);
        b[i].S=i;
        c[i].S=i;
    }
    sort(b,b+n,cmp);
    sort(c,c+n,cmp);

    double Ans=0;
    ll po1=b[0].S;
    ll po2=c[0].S;
    Ans+=b[0].F+c[0].F;
    if(po2==po1){
        Ans=min(b[0].F+c[1].F,b[1].F+c[0].F);
    }

    Ans=min(Ans,b[0].F);
    Ans=min(Ans,c[0].F);

    //cout<<po1<<" "<<po2<<" ";

    for(int i=0;i<n;i++){
        Ans+=2*dis(p0,a[i]);
    }

    cout<<fixed<<setprecision(12)<<Ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll mod=1e18;
int poww(int a,int b,int mod){
    int res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

/*ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}*/
/*ll add(ll a,ll b){
    ll ret=1ll*(a%mod)+1ll*(b%mod);
    ret%=mod;
    if(ret<0) ret+=mod;
    R ret;
}
*/
/*ll mul(ll a,ll b){
    ll ret=1ll*(a%mod)*(b%mod);
    ret%=mod;
    R ret;
}
*/
void min_self(ll& x,ll y){
x=min(x,y);
}

struct point{
int x,y;
};

point a[200200];
pair<long double,int> b[200200],c[200200];
ll n;

long double dis(point a,point b){
R sqrt( (b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y) );
}

bool cmp(pair<long double,int> a1,pair<long double,int> a2){
    R (a1.F<a2.F);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    point p1,p2,p0;
    cin>>p1.x>>p1.y>>p2.x>>p2.y>>p0.x>>p0.y;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].x>>a[i].y;
    }
    for(int i=0;i<n;i++){
        b[i].F=dis(p1,a[i])-dis(p0,a[i]);
        c[i].F=dis(p2,a[i])-dis(p0,a[i]);
        b[i].S=i;
        c[i].S=i;
    }
    sort(b,b+n,cmp);
    sort(c,c+n,cmp);

    long double Ans=0;
    int po1=b[0].S;
    int po2=c[0].S;
    Ans+=b[0].F+c[0].F;
    if(po2==po1){
        if(b[1].F<c[1].F){
            po1=b[1].S;
            Ans+=b[1].F-b[0].F;
        }
        else{
            po2=c[1].S;
            Ans+=c[1].F-c[0].F;
        }
    }

    //cout<<po1<<" "<<po2<<" ";

    for(int i=0;i<n;i++){
        Ans+=2*dis(p0,a[i]);
    }
    cout<<fixed<<setprecision(12)<<Ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll mod=1e18;
int poww(int a,int b,int mod){
    int res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

/*ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}*/
/*ll add(ll a,ll b){
    ll ret=1ll*(a%mod)+1ll*(b%mod);
    ret%=mod;
    if(ret<0) ret+=mod;
    R ret;
}
*/
/*ll mul(ll a,ll b){
    ll ret=1ll*(a%mod)*(b%mod);
    ret%=mod;
    R ret;
}
*/
void min_self(ll& x,ll y){
x=min(x,y);
}

struct point{
ll x,y;
};

point a[200200];
pair<double,int> b[200200],c[200200];
ll n;

double dis(point a,point b){
R sqrt( (b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y) );
}

bool cmp(pair<double,int> a1,pair<double,int> a2){
    R (a1.F<a2.F);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    point p1,p2,p0;
    cin>>p1.x>>p1.y>>p2.x>>p2.y>>p0.x>>p0.y;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].x>>a[i].y;
    }
    for(int i=0;i<n;i++){
        b[i].F=dis(p1,a[i])-dis(p0,a[i]);
        c[i].F=dis(p2,a[i])-dis(p0,a[i]);
        b[i].S=i;
        c[i].S=i;
    }
    sort(b,b+n,cmp);
    sort(c,c+n,cmp);

    double Ans=0;
    int po1=b[0].S;
    int po2=c[0].S;
    Ans+=b[0].F+c[0].F;
    if(po2==po1){
        if(b[1].F<c[1].F){
            po1=b[1].S;
            Ans+=b[1].F-b[0].F;
        }
        else{
            po2=c[1].S;
            Ans+=c[1].F-c[0].F;
        }
    }

    //cout<<po1<<" "<<po2<<" ";

    for(int i=0;i<n;i++){
        Ans+=2*dis(p0,a[i]);
    }
    cout<<fixed<<setprecision(12)<<Ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define R return
#define B break
#define C continue
#define sf scanf
#define pf printf
#define pb push_back
#define F first
#define S second

using namespace std;

ll mod=1e18;
int poww(int a,int b,int mod){
    int res=1;if(b<0)b=(b%(mod-1)+mod-1)%(mod-1);
    for(;b;b>>=1,a=1ll*a*a%mod)
      if(b&1)res=1ll*res*a%mod;
    return res;
}

/*ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}*/
/*ll add(ll a,ll b){
    ll ret=1ll*(a%mod)+1ll*(b%mod);
    ret%=mod;
    if(ret<0) ret+=mod;
    R ret;
}
*/
/*ll mul(ll a,ll b){
    ll ret=1ll*(a%mod)*(b%mod);
    ret%=mod;
    R ret;
}
*/
void min_self(ll& x,ll y){
x=min(x,y);
}

struct point{
ll x,y;
};

point a[200200];
pair<long double,ll> b[200200],c[200200];
ll n;

long double dis(point a,point b){
R sqrt( (b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y) );
}

bool cmp(pair<long double,ll> a1,pair<long double,ll> a2){
    R (a1.F<a2.F);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    point p1,p2,p0;
    cin>>p1.x>>p1.y>>p2.x>>p2.y>>p0.x>>p0.y;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].x>>a[i].y;
    }
    for(int i=0;i<n;i++){
        b[i].F=dis(p1,a[i])-dis(p0,a[i]);
        c[i].F=dis(p2,a[i])-dis(p0,a[i]);
        b[i].S=i;
        c[i].S=i;
    }
    sort(b,b+n,cmp);
    sort(c,c+n,cmp);

    long double Ans=0;
    ll po1=b[0].S;
    ll po2=c[0].S;
    Ans+=b[0].F+c[0].F;
    if(po2==po1){
        if(b[1].F<c[1].F){
            po1=b[1].S;
            Ans+=b[1].F-b[0].F;
        }
        else{
            po2=c[1].S;
            Ans+=c[1].F-c[0].F;
        }
    }

    //cout<<po1<<" "<<po2<<" ";

    for(int i=0;i<n;i++){
        Ans+=2*dis(p0,a[i]);
    }
    cout<<fixed<<setprecision(12)<<Ans<<'\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int ax, ay, bx, by, tx, ty;
  scanf("%d %d %d %d %d %d", &ax, &ay, &bx, &by, &tx, &ty);
  double dist = 0;
  int idx1[2] = {-1, -2};
  int idx2[2] = {-1, -2};
  double dist1[2] = {0, DBL_MAX};
  double dist2[2] = {0, DBL_MAX};
  int n; scanf("%d", &n);
  for(int j = 0; j<n; j++){
    double x, y; scanf("%lf %lf", &x, &y);
    double d = sqrt((x-tx)*(x-tx)+(y-ty)*(y-ty));
    dist += d;
    double savings1 = sqrt((x-ax)*(x-ax)+(y-ay)*(y-ay))-d;
    double savings2 = sqrt((x-bx)*(x-bx)+(y-by)*(y-by))-d;
    for(int i = 0; i<2; i++){
      if(savings1 < dist1[i]){
        if(i == 0){
          dist1[1] = dist1[0];
          idx1[1] = idx1[0];
        }
        dist1[i] = savings1;
        idx1[i] = j;
        break;
      }
    }
    for(int i = 0; i<2; i++){
      if(savings2 < dist2[i]){
        if(i == 0){
          dist2[1] = dist2[0];
          idx2[1] = idx2[0];
        }
        dist2[i] = savings2;
        idx2[i] = j;
        break;
      }
    }
  }
  dist *= 2;
  if(idx1[0] == idx2[0]){
    dist += min(dist1[0]+dist2[1], dist1[1]+dist2[0]);
  }else{
    dist += dist1[0]+dist2[0];
  }
  printf("%6.13lf\n", dist);
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int ax, ay, bx, by, tx, ty;
  scanf("%d %d %d %d %d %d", &ax, &ay, &bx, &by, &tx, &ty);
  double dist = 0;
  int idx1[2] = {-1, -2};
  int idx2[2] = {-1, -2}
  double dist1[2] = {0,0};
  double dist2[2] = {0,0};
  int n; scanf("%d", &n);
  for(int j = 0; j<n; j++){
    double x, y; scanf("%lf %lf", &x, &y);
    double d = sqrt((x-tx)*(x-tx)+(y-ty)*(y-ty));
    dist += d;
    double savings1 = sqrt((x-ax)*(x-ax)+(y-ay)*(y-ay))-d;
    double savings2 = sqrt((x-bx)*(x-bx)+(y-by)*(y-by))-d;
    for(int i = 0; i<2; i++){
      if(savings1 < dist1[i]){
        if(i == 0){
          dist1[1] = dist1[0];
          idx1[1] = idx1[0];
        }
        dist1[i] = savings1;
        idx1[i] = j;
        break;
      }
    }
    for(int i = 0; i<2; i++){
      if(savings2 < dist2[i]){
        if(i == 0){
          dist2[1] = dist2[0];
          idx2[1] = idx2[0];
        }
        dist2[i] = savings2;
        idx2[i] = j;
        break;
      }
    }
  }
  dist *= 2;
  if(n == 1){
    if(dist1[0] < dist2[0])
      dist += dist1[0];
    else
      dist += dist2[0];
  }else if(idx1[0] == idx2[0]){
    dist += min(dist1[0]+dist2[1], dist1[1]+dist2[0]);
  }else{
    dist += dist1[0]+dist2[0];
  }
  printf("%6.13lf\n", dist);
}


#include <bits/stdc++.h>
using namespace std;
#define LL_MAX (1LL<<40)
#define double long double
int main(){
  int ax, ay, bx, by, tx, ty;
  scanf("%d %d %d %d %d %d", &ax, &ay, &bx, &by, &tx, &ty);
  double dist = 0;
  int idx1[2];
  int idx2[2];
  double dist1[2] = {LL_MAX, LL_MAX};
  double dist2[2] = {LL_MAX, LL_MAX};
  int n; scanf("%d", &n);
  for(int j = 0; j<n; j++){
    double x, y; scanf("%LG %LG", &x, &y);
    double d = sqrt((x-tx)*(x-tx)+(y-ty)*(y-ty));
    dist += d;
    double savings1 = sqrt((x-ax)*(x-ax)+(y-ay)*(y-ay))-d;
    double savings2 = sqrt((x-bx)*(x-bx)+(y-by)*(y-by))-d;
    for(int i = 0; i<2; i++){
      if(savings1 < dist1[i]){
        if(i == 0){
          dist1[1] = dist1[0];
          idx1[1] = idx1[0];
        }
        dist1[i] = savings1;
        idx1[i] = j;
        break;
      }
    }
    for(int i = 0; i<2; i++){
      if(savings2 < dist2[i]){
        if(i == 0){
          dist2[1] = dist2[0];
          idx2[1] = idx2[0];
        }
        dist2[i] = savings2;
        idx2[i] = j;
        break;
      }
    }
  }
  dist *= 2;
  if(n == 1){
    if(dist1[0] < dist2[0])
      dist += dist1[0];
    else
      dist += dist2[0];
  }else if(idx1[0] == idx2[0]){
    dist += min(dist1[0]+dist2[1], dist1[1]+dist2[0]);
  }else{
    dist += dist1[0]+dist2[0];
  }
  printf("%6.13LG\n", dist);
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int ax, ay, bx, by, tx, ty;
  scanf("%d %d %d %d %d %d", &ax, &ay, &bx, &by, &tx, &ty);
  double dist = 0;
  int idx1[2] = {-1, -2};
  int idx2[2] = {-1, -2};
  double dist1[2] = {0,0};
  double dist2[2] = {0,0};
  int n; scanf("%d", &n);
  for(int j = 0; j<n; j++){
    double x, y; scanf("%lf %lf", &x, &y);
    double d = sqrt((x-tx)*(x-tx)+(y-ty)*(y-ty));
    dist += d;
    double savings1 = sqrt((x-ax)*(x-ax)+(y-ay)*(y-ay))-d;
    double savings2 = sqrt((x-bx)*(x-bx)+(y-by)*(y-by))-d;
    for(int i = 0; i<2; i++){
      if(savings1 < dist1[i]){
        if(i == 0){
          dist1[1] = dist1[0];
          idx1[1] = idx1[0];
        }
        dist1[i] = savings1;
        idx1[i] = j;
        break;
      }
    }
    for(int i = 0; i<2; i++){
      if(savings2 < dist2[i]){
        if(i == 0){
          dist2[1] = dist2[0];
          idx2[1] = idx2[0];
        }
        dist2[i] = savings2;
        idx2[i] = j;
        break;
      }
    }
  }
  dist *= 2;
  if(n == 1){
    if(dist1[0] < dist2[0])
      dist += dist1[0];
    else
      dist += dist2[0];
  }else if(idx1[0] == idx2[0]){
    dist += min(dist1[0]+dist2[1], dist1[1]+dist2[0]);
  }else{
    dist += dist1[0]+dist2[0];
  }
  printf("%6.13lf\n", dist);
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int ax, ay, bx, by, tx, ty;
  scanf("%d %d %d %d %d %d", &ax, &ay, &bx, &by, &tx, &ty);
  double dist = 0;
  int idx1[2] = {-1, -2};
  int idx2[2] = {-1, -2};
  double dist1[2] = {0, DBL_MAX};
  double dist2[2] = {0, DBL_MAX};
  int n; scanf("%d", &n);
  for(int j = 0; j<n; j++){
    double x, y; scanf("%lf %lf", &x, &y);
    double d = sqrt((x-tx)*(x-tx)+(y-ty)*(y-ty));
    dist += d;
    double savings1 = sqrt((x-ax)*(x-ax)+(y-ay)*(y-ay))-d;
    double savings2 = sqrt((x-bx)*(x-bx)+(y-by)*(y-by))-d;
    for(int i = 0; i<2; i++){
      if(savings1 < dist1[i]){
        if(i == 0){
          dist1[1] = dist1[0];
          idx1[1] = idx1[0];
        }
        dist1[i] = savings1;
        idx1[i] = j;
        break;
      }
    }
    for(int i = 0; i<2; i++){
      if(savings2 < dist2[i]){
        if(i == 0){
          dist2[1] = dist2[0];
          idx2[1] = idx2[0];
        }
        dist2[i] = savings2;
        idx2[i] = j;
        break;
      }
    }
  }
  dist *= 2;
  if(n == 1){
    if(dist1[0] < dist2[0])
      dist += dist1[0];
    else
      dist += dist2[0];
  }else if(idx1[0] == idx2[0]){
    dist += min(dist1[0]+dist2[1], dist1[1]+dist2[0]);
  }else{
    dist += dist1[0]+dist2[0];
  }
  printf("%6.13lf\n", dist);
}


#include <bits/stdc++.h>
using namespace std;
#define LL_MAX (1LL<<40)
#define double long double
int main(){
  int ax, ay, bx, by, tx, ty;
  scanf("%d %d %d %d %d %d", &ax, &ay, &bx, &by, &tx, &ty);
  double dist = 0;
  int idx1[2];
  int idx2[2];
  double dist1[2] = {LL_MAX, LL_MAX};
  double dist2[2] = {LL_MAX, LL_MAX};
  int n; scanf("%d", &n);
  for(int j = 0; j<n; j++){
    double x, y; scanf("%lf %lf", &x, &y);
    double d = sqrt((x-tx)*(x-tx)+(y-ty)*(y-ty));
    dist += d;
    double savings1 = sqrt((x-ax)*(x-ax)+(y-ay)*(y-ay))-d;
    double savings2 = sqrt((x-bx)*(x-bx)+(y-by)*(y-by))-d;
    for(int i = 0; i<2; i++){
      if(savings1 < dist1[i]){
        if(i == 0){
          dist1[1] = dist1[0];
          idx1[1] = idx1[0];
        }
        dist1[i] = savings1;
        idx1[i] = j;
        break;
      }
    }
    for(int i = 0; i<2; i++){
      if(savings2 < dist2[i]){
        if(i == 0){
          dist2[1] = dist2[0];
          idx2[1] = idx2[0];
        }
        dist2[i] = savings2;
        idx2[i] = j;
        break;
      }
    }
  }
  dist *= 2;
  if(n == 1){
    if(dist1[0] < dist2[0])
      dist += dist1[0];
    else
      dist += dist2[0];
  }else if(idx1[0] == idx2[0]){
    dist += min(dist1[0]+dist2[1], dist1[1]+dist2[0]);
  }else{
    dist += dist1[0]+dist2[0];
  }
  printf("%6.13lf\n", dist);
}


#include <bits/stdc++.h>
using namespace std;
#define LL_MAX (1LL<<40)
int main(){
  int ax, ay, bx, by, tx, ty;
  scanf("%d %d %d %d %d %d", &ax, &ay, &bx, &by, &tx, &ty);
  double dist = 0;
  int idx1[2];
  int idx2[2];
  double dist1[2] = {LL_MAX, LL_MAX};
  double dist2[2] = {LL_MAX, LL_MAX};
  int n; scanf("%d", &n);
  for(int j = 0; j<n; j++){
    double x, y; scanf("%lf %lf", &x, &y);
    double d = sqrt((x-tx)*(x-tx)+(y-ty)*(y-ty));
    dist += d;
    double savings1 = sqrt((x-ax)*(x-ax)+(y-ay)*(y-ay))-d;
    double savings2 = sqrt((x-bx)*(x-bx)+(y-by)*(y-by))-d;
    for(int i = 0; i<2; i++){
      if(savings1 < dist1[i]){
        if(i == 0){
          dist1[1] = dist1[0];
          idx1[1] = idx1[0];
        }
        dist1[i] = savings1;
        idx1[i] = j;
        break;
      }
    }
    for(int i = 0; i<2; i++){
      if(savings2 < dist2[i]){
        if(i == 0){
          dist2[1] = dist2[0];
          idx2[1] = idx2[0];
        }
        dist2[i] = savings2;
        idx2[i] = j;
        break;
      }
    }
  }
  dist *= 2;
  if(n == 1){
    if(dist1[0] < dist2[0])
      dist += dist1[0];
    else
      dist += dist2[0];
  }else if(idx1[0] == idx2[0]){
    dist += min(dist1[0]+dist2[1], dist1[1]+dist2[0]);
  }else{
    dist += dist1[0]+dist2[0];
  }
  printf("%6.13lf\n", dist);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){cin >> x;}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x; scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<double> distances;
  distances.reserve(n);
  transform(points.begin(), points.end(), back_inserter(distances), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n);
  bera_indices.reserve(n);

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices[i] = {a - distances[i], i};
    bera_indices[i] = {b - distances[i], i};
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 2e9;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else if(n > 1) {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

#define double double

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){cin >> x;}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x; scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<double> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n+1);
  bera_indices.reserve(n+1);
  adil_indices.push_back({0.0, n});
  bera_indices.push_back({0.0, n+1});

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 0.0;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){
  cin >> x;
}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x;
  scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  //ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<double> distances;
  distances.reserve(n);
  transform(points.begin(), points.end(), back_inserter(distances), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n);
  bera_indices.reserve(n);

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 2e9;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else if(n > 1) {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

istream& operator>>(istream& in, pair<double,double>& p) {
  return in >> p.first >> p.second;
}

ostream& operator<<(ostream& out, pair<double,double> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){cin >> x;}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x; scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

typedef long long ll;
typedef long double ld;
typedef pair<double,double> point;

/***********************************************************************/

ld dist(point const& a, point const& b) {
  ld dx = a.first - b.first;
  ld dy = a.second - b.second;
  return sqrt(dx*dx + dy*dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<ld> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  ld total = 2*accumulate(distances.begin(), distances.end(), 0.0, plus<ld>());

  // <delta,index>
  vector<pair<ld,int>> adil_indices;
  vector<pair<ld,int>> bera_indices;
  adil_indices.reserve(n+1);
  bera_indices.reserve(n+1);
  adil_indices.push_back({0.0, n});
  bera_indices.push_back({0.0, n+1});

  for(int i = 0; i < n; ++i) {
    ld a = dist(adil, points[i]);
    ld b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  ld smallest = 0.0;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

istream& operator>>(istream& in, pair<int,int>& p) {
  return in >> p.first >> p.second;
}

ostream& operator<<(ostream& out, pair<int,int> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T>
void scan(T& x) {
  cin >> x;
}

template<class T, class... Args>
void scan(T& x, Args& ...abc) {
  cin >> x;
  scan(abc...);
}

template<class T>
void put(T const& x) {
  cout << x;
}

template<class T, class... Args>
void put(T const& x, Args const& ...abc) {
  cout << x << ' ';
  put(abc...);
}

template<class T>
void putln(T const& x) {
  cout << x << endl;
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl;
  putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

typedef long long ll;
typedef pair<int,int> point;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return sqrt(dx*dx + dy*dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<double> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n+1);
  bera_indices.reserve(n+1);

  for(int i = 0; i < n; ++i) {
    auto a = dist(adil, points[i]);
    auto b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }
  adil_indices.push_back({0, n});
  bera_indices.push_back({0, n+1});

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 0.0;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

char *fmt[] = {"N/A", "%d", "%lld", "%c", "%f", "%s"};

template<class T>
constexpr int getfmt(T x) {
  return 0;
}

template<>
constexpr int getfmt<int>(int x) {
  return 1;
}

template<>
constexpr int getfmt<ll>(ll x) {
  return 2;
}

template<>
constexpr int getfmt<char>(char x) {
  return 3;
}

template<>
constexpr int getfmt<float>(float x) {
  return 4;
}

template<>
constexpr int getfmt<double>(double x) {
  return 4;
}

template<>
constexpr int getfmt<char*>(char* x) {
  return 5;
}

template<class T> void scan(T& x){
  //cin >> x;
  scanf(fmt[getfmt(x)], &x);
}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  //cin >> x;
  scanf(fmt[getfmt(x)], &x);
  scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  //ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil.first, adil.second, bera.first, bera.second, bin.first, bin.second, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p.first, p.second);});

  vector<double> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n);
  bera_indices.reserve(n);

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 2e9;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else if(n > 1) {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

istream& operator>>(istream& in, pair<int,int>& p) {
  return in >> p.first >> p.second;
}

ostream& operator<<(ostream& out, pair<int,int> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T>
void scan(T& x) {
  cin >> x;
}

template<class T, class... Args>
void scan(T& x, Args& ...abc) {
  cin >> x;
  scan(abc...);
}

template<class T>
void put(T const& x) {
  cout << x;
}

template<class T, class... Args>
void put(T const& x, Args const& ...abc) {
  cout << x << ' ';
  put(abc...);
}

template<class T>
void putln(T const& x) {
  cout << x << endl;
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl;
  putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

/***********************************************************************/

ld dist(point const& a, point const& b) {
  ld dx = a.first - b.first;
  ld dy = a.second - b.second;
  return sqrt(dx*dx + dy*dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<ld> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  ld total = 2*accumulate(distances.begin(), distances.end(), 0.0, plus<ld>());

  // <delta,index>
  vector<pair<ld,int>> adil_indices;
  vector<pair<ld,int>> bera_indices;
  adil_indices.reserve(n+1);
  bera_indices.reserve(n+1);
  adil_indices.push_back({0.0, n});
  bera_indices.push_back({0.0, n+1});

  for(int i = 0; i < n; ++i) {
    ld a = dist(adil, points[i]);
    ld b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  ld smallest = 0.0;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

istream& operator>>(istream& in, pair<int,int>& p) {
  return in >> p.first >> p.second;
}

ostream& operator<<(ostream& out, pair<int,int> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T>
void scan(T& x) {
  cin >> x;
}

template<class T, class... Args>
void scan(T& x, Args& ...abc) {
  cin >> x;
  scan(abc...);
}

template<class T>
void put(T const& x) {
  cout << x;
}

template<class T, class... Args>
void put(T const& x, Args const& ...abc) {
  cout << x << ' ';
  put(abc...);
}

template<class T>
void putln(T const& x) {
  cout << x << endl;
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl;
  putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(10);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

typedef long long ll;
typedef pair<int,int> point;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return sqrt(dx*dx + dy*dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<double> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta>
  set<double> adil_indices;
  set<double> bera_indices;

  for(int i = 0; i < n; ++i) {
    auto a = dist(adil, points[i]);
    auto b = dist(bera, points[i]);

    adil_indices.insert(a - distances[i]);
    bera_indices.insert(b - distances[i]);
  }

  auto a1 = adil_indices.size() ? *adil_indices.begin() : 0;
  auto a2 = adil_indices.size() > 1 ? *next(adil_indices.begin()) : 0;

  auto b1 = bera_indices.size() ? *bera_indices.begin() : 0;
  auto b2 = bera_indices.size() > 1 ? *next(bera_indices.begin()) : 0;

  total += min(a1+b2, min(a2+b1, 0.0));

  putln(total);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){cin >> x;}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x; scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points;
  points.resize(n);
  for(auto & x : points)
    scan(x);

  vector<double> distances;
  distances.reserve(n);
  transform(points.begin(), points.end(), back_inserter(distances), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n);
  bera_indices.reserve(n);

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices.emplace_back(make_pair(a - distances[i], i));
    bera_indices.emplace_back(make_pair(b - distances[i], i));
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 2e9;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else if(n > 1) {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){cin >> x;}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x; scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

point points[(int)3e5];
double distances[(int)3e5];
pair<double,int> adil_indices[(int)3e5];
pair<double,int> bera_indices[(int)3e5];

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  //vector<point> points(n);
  for_each(points, points + n, [](point& p){scan(p);});

  //vector<double> distances(n);
  transform(points, points + n, distances, [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances, distances + n, 0.0, plus<double>());

  // <delta,index>
  //vector<pair<double,int>> adil_indices;
  //vector<pair<double,int>> bera_indices;
  //adil_indices.reserve(n);
  //bera_indices.reserve(n);

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices[i].first = (a - distances[i]);
    bera_indices[i].first = (b - distances[i]);
    adil_indices[i].second = bera_indices[i].second = i;
  }

  sort(adil_indices, adil_indices + n);
  sort(bera_indices, bera_indices + n);

  double smallest = 2e9;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else if(n > 1) {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){
  cin >> x;
}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x;
  scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  //ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<double> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n);
  bera_indices.reserve(n);

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 2e9;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else if(n > 1) {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

istream& operator>>(istream& in, pair<int,int>& p) {
  return in >> p.first >> p.second;
}

ostream& operator<<(ostream& out, pair<int,int> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T>
void scan(T& x) {
  cin >> x;
}

template<class T, class... Args>
void scan(T& x, Args& ...abc) {
  cin >> x;
  scan(abc...);
}

template<class T>
void put(T const& x) {
  cout << x;
}

template<class T, class... Args>
void put(T const& x, Args const& ...abc) {
  cout << x << ' ';
  put(abc...);
}

template<class T>
void putln(T const& x) {
  cout << x << endl;
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl;
  putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(10);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

typedef long long ll;
typedef pair<int,int> point;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return sqrt(dx*dx + dy*dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<double> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n+1);
  bera_indices.reserve(n+1);

  for(int i = 0; i < n; ++i) {
    auto a = dist(adil, points[i]);
    auto b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }
  adil_indices.push_back({0, n});
  bera_indices.push_back({0, n+1});

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 0.0;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);
  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(adil_indices[0].first + bera_indices[0].first, smallest);
  } else {
    smallest = min(adil_indices[1].first + bera_indices[0].first, smallest);
    smallest = min(adil_indices[0].first + bera_indices[1].first, smallest);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

char *fmt[] = {"N/A", "%d", "%lld", "%c", "%f", "%s"};

template<class T>
constexpr int getfmt(T x) {
  return 0;
}

template<>
constexpr int getfmt<int>(int x) {
  return 1;
}

template<>
constexpr int getfmt<ll>(ll x) {
  return 2;
}

template<>
constexpr int getfmt<char>(char x) {
  return 3;
}

template<>
constexpr int getfmt<float>(float x) {
  return 4;
}

template<>
constexpr int getfmt<double>(double x) {
  return 4;
}

template<>
constexpr int getfmt<char*>(char* x) {
  return 5;
}

template<class T> void scan(T& x){
  //cin >> x;
  scanf(fmt[getfmt(x)], &x);
}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  //cin >> x;
  scanf(fmt[getfmt(x)], &x);
  scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  //ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  //cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil.first, adil.second, bera.first, bera.second, bin.first, bin.second, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p.first, p.second);});

  vector<double> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n);
  bera_indices.reserve(n);

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 2e9;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else if(n > 1) {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  printf("%.12f\n", total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> point;

istream& operator>>(istream& in, pair<ld,ld>& p) {
  return in >> p.first >> p.second;
}

ostream& operator<<(ostream& out, pair<ld,ld> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){cin >> x;}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x; scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

ld dist(point const& a, point const& b) {
  ld dx = a.first - b.first;
  ld dy = a.second - b.second;
  return sqrt(dx*dx + dy*dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<ld> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  ld total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<ld>());

  // <delta,index>
  vector<pair<ld,int>> adil_indices;
  vector<pair<ld,int>> bera_indices;
  adil_indices.reserve(n+1);
  bera_indices.reserve(n+1);
  adil_indices.push_back({0.0, n});
  bera_indices.push_back({0.0, n+1});

  for(int i = 0; i < n; ++i) {
    ld a = dist(adil, points[i]);
    ld b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  ld smallest = 0.0;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')
#define mkp(x,y) make_pair(x,y)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){cin >> x;}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x; scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points;
  points.reserve(n);
  point x;
  for(int i = 0; i < n; ++i) {scan(x);points.emplace_back(x);}

  vector<double> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n);
  bera_indices.reserve(n);

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices.emplace_back(make_pair(a - distances[i], i));
    bera_indices.emplace_back(make_pair(b - distances[i], i));
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 2e9;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else if(n > 1) {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){cin >> x;}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x; scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<double> distances(n);
  transform(points.begin(), points.end(), distances.begin(), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices;
  vector<pair<double,int>> bera_indices;
  adil_indices.reserve(n);
  bera_indices.reserve(n);

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices.push_back({a - distances[i], i});
    bera_indices.push_back({b - distances[i], i});
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 2e9;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else if(n > 1) {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}


/***********************************************************************/
#include <bits/stdc++.h>

#define endl ('\n')

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> point;

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1,T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, pair<T1,T2> const& p) {
  return out << p.first << ' ' << p.second;
}

template<class T> void scan(T& x){cin >> x;}

template<class T, class... Args>void scan(T& x, Args& ...abc){
  cin >> x; scan(abc...);
}

template<class T>void put(T const& x){cout << x;}
template<class T>void putln(T const& x){cout << x << endl;}

template<class T, class... Args>void put(T const& x, Args const& ...abc) {
  cout << x << ' '; put(abc...);
}

template<class T, class... Args>
void putln(T const& x, Args const& ...abc) {
  cout << x << endl; putln(abc...);
}

struct _ {
 _ () {
  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);cerr.tie(0);
  cout << fixed << setprecision(12);
  #ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  #endif
  }
} _;

/***********************************************************************/

double dist(point const& a, point const& b) {
  double dx = a.first - b.first;
  double dy = a.second - b.second;
  return hypot(dx, dy);
}

int main() {
  int n;
  point adil, bera, bin;
  scan(adil, bera, bin, n);
  vector<point> points(n);
  for_each(points.begin(), points.end(), [](point& p){scan(p);});

  vector<double> distances;
  distances.reserve(n);
  transform(points.begin(), points.end(), back_inserter(distances), [&bin](point const&p){
    return dist(p, bin);
  });

  double total = 2.0*accumulate(distances.begin(), distances.end(), 0.0, plus<double>());

  // <delta,index>
  vector<pair<double,int>> adil_indices(n);
  vector<pair<double,int>> bera_indices(n);

  for(int i = 0; i < n; ++i) {
    double a = dist(adil, points[i]);
    double b = dist(bera, points[i]);

    adil_indices[i] = {a - distances[i], i};
    bera_indices[i] = {b - distances[i], i};
  }

  sort(adil_indices.begin(), adil_indices.end());
  sort(bera_indices.begin(), bera_indices.end());

  double smallest = 2e9;
  smallest = min(smallest, adil_indices[0].first);
  smallest = min(smallest, bera_indices[0].first);

  if(adil_indices[0].second != bera_indices[0].second) {
    smallest = min(smallest, adil_indices[0].first + bera_indices[0].first);
  } else if(n > 1) {
    smallest = min(smallest, adil_indices[1].first + bera_indices[0].first);
    smallest = min(smallest, adil_indices[0].first + bera_indices[1].first);
  }

  putln(total + smallest);
}