import java.io.*;
import java.util.*;
public final class round_352_c
{
static double[] dis1,dis2;
static Pair[] tree;
static double pow(double val1)
{
return (val1*val1);
}
static double getDis(double x1,double y1,double x2,double y2)
{
return Math.
sqrt(pow
(x2
-x1
)+pow
(y2
-y1
)); }
static void build(int node,int l,int r)
{
if(l>r)
{
return;
}
if(l==r)
{
tree[node]=new Pair(l,dis2[l]);
}
else
{
int mid=(l+r)>>1;
build(node<<1,l,mid);
build(node<<1|1,mid+1,r);
if(tree[node<<1].val<=tree[node<<1|1].val)
{
tree[node]=new Pair(tree[node<<1].idx,tree[node<<1].val);
}
else
{
tree[node]=new Pair(tree[node<<1|1].idx,tree[node<<1|1].val);
}
}
}
static Pair get(int node,int s,int e,int l,int r)
{
if(s>e || l>e || r<s)
{
return new Pair
(-1,
Double.
MAX_VALUE); }
if(l<=s && r>=e)
{
return tree[node];
}
else
{
int mid=(s+e)>>1;
Pair q1=get(node<<1,s,mid,l,r);
Pair q2=get(node<<1|1,mid+1,e,l,r);
if(q1.val<=q2.val)
{
return q1;
}
else
{
return q2;
}
}
}
{
double x1=sc.nextDouble(),y1=sc.nextDouble(),x2=sc.nextDouble(),y2=sc.nextDouble(),x3=sc.nextDouble(),y3=sc.nextDouble();
int n=sc.nextInt();
Node[] a=new Node[n];
for(int i=0;i<n;i++)
{
a[i]=new Node(sc.nextDouble(),sc.nextDouble());
}
dis1=new double[n];dis2=new double[n];
double sum1=0;
for(int i=0;i<n;i++)
{
dis1[i]=getDis(a[i].x1,a[i].y1,x3,y3)+getDis(a[i].x1,a[i].y1,x3,y3);
sum1=sum1+dis1[i];
}
for(int i=0;i<n;i++)
{
double curr=getDis(a[i].x1,a[i].y1,x1,y1)+getDis(a[i].x1,a[i].y1,x3,y3);
double val1=sum1-dis1[i]+curr;
curr=getDis(a[i].x1,a[i].y1,x2,y2)+getDis(a[i].x1,a[i].y1,x3,y3);
val1=sum1-dis1[i]+curr;
}
for(int i=0;i<n;i++)
{
dis2[i]=getDis(a[i].x1,a[i].y1,x1,y1)+getDis(a[i].x1,a[i].y1,x3,y3);
}
tree=new Pair[4*n];
build(1,0,n-1);
for(int i=0;i<n;i++)
{
double val1
=getDis
(a
[i
].
x1,a
[i
].
y1,x2,y2
)+getDis
(a
[i
].
x1,a
[i
].
y1,x3,y3
),min_val
=Double.
MAX_VALUE; int minidx=-1;
Pair n1
=get
(1,
0,n
-1,
0,
Math.
max(0,i
-1)),n2
=get
(1,
0,n
-1,
Math.
min(i
+1,n
-1),n
-1); if(n1.idx!=-1)
{
if(n1.val<min_val)
{
min_val=n1.val;
minidx=n1.idx;
}
}
if(n2.idx!=-1)
{
if(n2.val<min_val)
{
min_val=n2.val;
minidx=n2.idx;
}
}
{
double curr=sum1-dis1[i]-dis1[minidx]+val1+min_val;
//out.println(min);
}
}
out.printf("%.12f\n",min);
out.close();
}
}
class Node
{
double x1,y1;
public Node(double x1,double y1)
{
this.x1=x1;
this.y1=y1;
}
}
class Pair
{
int idx;
double val;
public Pair(int idx,double val)
{
this.idx=idx;
this.val=val;
}
}
class FastScanner
{
this.in = in;
}
while (st == null || !st.hasMoreTokens()) {
}
return st.nextToken();
}
return nextToken().toString();
}
return Integer.
parseInt(nextToken
()); }
return Long.
parseLong(nextToken
()); }
public double nextDouble
() throws Exception { return Double.
parseDouble(nextToken
()); }
}
aW1wb3J0IGphdmEuaW8uKjsKaW1wb3J0IGphdmEudXRpbC4qOwpwdWJsaWMgZmluYWwgY2xhc3Mgcm91bmRfMzUyX2MKewogICAgc3RhdGljIEZhc3RTY2FubmVyIHNjPW5ldyBGYXN0U2Nhbm5lcihuZXcgQnVmZmVyZWRSZWFkZXIobmV3IElucHV0U3RyZWFtUmVhZGVyKFN5c3RlbS5pbikpKTsKICAgIHN0YXRpYyBQcmludFdyaXRlciBvdXQ9bmV3IFByaW50V3JpdGVyKFN5c3RlbS5vdXQpOwoJc3RhdGljIGRvdWJsZVtdIGRpczEsZGlzMjsKCXN0YXRpYyBQYWlyW10gdHJlZTsKCQoJc3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rZW4oKSk7CiAgICB9CgogICAgcHVibGljIGxvbmcgbmV4dExvbmcoKSB0aHJvd3MgRXhjZXB0aW9uIHsKICAgICAgICByZXR1cm4gTG9uZy5wYXJzZUxvbmcobmV4dFRva2VuKCkpOwogICAgfQoKICAgIHB1YmxpYyBkb3VibGUgbmV4dERvdWJsZSgpIHRocm93cyBFeGNlcHRpb24gewogICAgICAgIHJldHVybiBEb3VibGUucGFyc2VEb3VibGUobmV4dFRva2VuKCkpOwogICAgfQp9