Problem: You have got a new job, and it's very interesting, you are a ship captain. Your first task is to move your ship from one point to another point, and for sure you want to move it at the minimum cost.

And it's well known that the shortest distance between any 2 points is the length of the line segment between these 2 points. But unfortunately there is an island in the sea, so sometimes you won't be able to move your ship in the line segment between the 2 points.

You can only move to safe points. A point is called safe if it's on the line segment between the start and end points, or if it's on the island's edge.

But you are too lucky, you have got some clever and strong workers and they can help you in your trip, they can help you move the ship in the sea and they will take 1 Egyptian pound for each moving unit in the sea, and they can carry the ship (yes, they are very strong) and walk on the island and they will take 2 Egyptian pounds for each moving unit in the island. The money which you will give to them will be divided between all workers, so the number of workers does not matter here.

You can move your ship on the island edge, and it will be considered moving in the sea.

Now you have a sea map, and you have to decide what is the minimum cost for your trip.

Your starting point is (xStart, yStart), and the end point is (xEnd, yEnd), both points will be different.

The island will be a convex polygon and there will be no more than 2 polygon points on the same line, also the starting and the end points won't be inside or on the boundary of the island. The points for the polygon will be given in the anti-clockwise order.

Input

The first line contains 4 integers, xStart, yStart, xEnd and yEnd ( - 100 ≤ xStart, yStart, xEnd, yEnd ≤ 100). The second line contains an integer n, which is the number of points in the polygon (3 ≤ n ≤ 30), followed by a line containing n pairs of integers x and y, which are the coordinates of the points ( - 100 ≤ x, y ≤ 100), the polygon points will be distinct.

Output

Print one line which contains the minimum possible cost. The absolute or relative error in the answer should not exceed 10 - 6.

Examples

Input

1 7 6 7
4
4 2 4 12 3 12 3 2


Output

6.000000000


Input

-1 0 2 0
4
0 0 1 0 1 1 0 1


Output

3.000000000

Solution (in JAVA):

Solution:
import static java.lang.Math.PI;
import static java.lang.Math.abs;
import static java.lang.Math.acos;
import static java.lang.Math.cos;
import static java.lang.Math.min;
import static java.lang.Math.sin;
import static java.lang.Math.sqrt;
import static java.lang.System.in;
import static java.lang.System.out;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
public class E75simpleGeometry {
	public static Scanner sc = new Scanner(in);
	StringBuilder sb = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public void run() throws IOException {
		String input;
		String[] inputArray;
		input = br.readLine(); 	inputArray = input.split(" ");
		P B = new P(Integer.valueOf(inputArray[0]),Integer.valueOf(inputArray[1]));
		P E = new P(Integer.valueOf(inputArray[2]),Integer.valueOf(inputArray[3]));
		input = br.readLine(); 	inputArray = input.split(" ");
		int n = Integer.valueOf(inputArray[0]);
		P[] ver = new P[50];
		input = br.readLine(); 	inputArray = input.split(" ");
		for (int i=0; i<n; i++){
			ver[i] = new P(Integer.valueOf(inputArray[2*i]),Integer.valueOf(inputArray[2*i+1]));
		}
		ver[n] = ver[0];
		double total =0;
		for (int i=0; i<n; i++) total +=ver[i].dist(ver[i+1]);
		S path = new S(B,E);
		S edge1=null,edge2=null;
		
		int i,j;
		for (i=0; i<n; i++)
			if (new S(ver[i],ver[i+1]).isIntersect(path)) {
					edge1 = new S(ver[i],ver[i+1]);
					break;
				}
		if (edge1==null ) {
			ln(B.dist(E));
			return;
		}
		j=i+1;
		if (path.isIntersect(ver[i+1])) j=i+2;
		//if (path.isIntersect(ver[i+2])) j=i+1;
		for (; j<n; j++)
			if (new S(ver[j],ver[j+1]).isIntersect(path)) {
				edge2 = new S(ver[j],ver[j+1]);
				break;
			}
		if (edge2 == null) {
			ln(B.dist(E));
			return;
		}
		if ( edge1.isParallel(path)){
			ln(B.dist(E));
			return;
		}
		P v1 = S.intersection(path, edge1);
		P v2 = S.intersection(path, edge2);
		double ans;
		if (B.dist(v2)<B.dist(v1)) ans = B.dist(v2) + v1.dist(E);
		else ans = B.dist(v1) + v2.dist(E);
		double dist =0;
		for (int k=i+1; k<j; k++) dist+=ver[k].dist(ver[k+1]);
		double round =v1.dist(ver[i+1]) + dist + ver[j].dist(v2);
		round = Math.min(round, total-round ); 
		ans += Math.min(round, 2*v1.dist(v2));
		ln(ans);
		return;
	}

	public static void main(String[] args) throws IOException {
		new E75simpleGeometry().run();
	}
	public static void ln(Object obj) {
		out.println(obj);
	}
	static class P{
		
			static final double EPS=1e-10;
			static int signum(double x){
				return x<-EPS?-1:x>EPS?1:0;
			}
		static Comparator<P> comp=new Comparator<P>(){
			public int compare(P p1, P p2) {
				return signum(p1.x-p2.x)!=0?signum(p1.x-p2.x):signum(p1.y-p2.y);
			}
		};
		public static  final P O=new P(0,0);
		final double x,y;
		P(double _x,double _y){
			x=_x;y=_y;
		}
		
		P add(P a){
			return new P(x+a.x,y+a.y);
		}
		P sub(P a){
			return new P(x-a.x,y-a.y);
		}
		P mul(P a){
			return new P(x*a.x-y*a.y,x*a.y+y*a.x);
		}
		P div(P a){
			double d2=a.dist2(O);
			return new P(dot(a,this)/d2,cross(a,this)/d2);
		}
		
		P conj(){
			return new P(x,-y);
		}
		
		static double dot(P a,P b){
			return  a.x*b.x+a.y*b.y;
		}
		
		static double cross(P a,P b){
			return  a.x*b.y-a.y*b.x;
		}
		
		double dist2(P p){
			return (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y);
		}
		
		double dist(P p){
			return sqrt(dist2(p));
		}
		public double norm(){
			return dist(O);
		}
		
		static int ccw(P a,P b,P c){
			b=b.sub(a);c=c.sub(a);
			if(cross(b,c)>EPS)return 1;
			if(cross(b,c)<-EPS)return -1;
			if(dot(b,c)<-EPS)return 2;
			if(b.norm()<c.norm()-EPS)return -2;
			return 0;
		}
		
		
		
		static double arg(P o,P a){
			P dir=a.sub(o);
			double s=acos(dir.x/dir.norm());
			return dir.y>=0?s:2*PI-s;
		}
		
		static double arg(P a,P b, P c){
			double angleA = P.arg(a,b);
			double angleB = P.arg(b,c);
			double angle =  Math.PI+angleA-angleB;
			if (angle-2*Math.PI>EPS) angle-=2*Math.PI;
			if (angle<EPS) angle+=2*Math.PI;
			return angle;
		}
		
		P rotate(P o,double arg){
			return this.add(this.sub(o).mul(new P(cos(arg),sin(arg))));
		}
		
		static double S2(P a,P b,P o){
			return cross(a.sub(o),b.sub(o));
		}
		static double S(P a,P b,P o){
			return S2(a,b,o)/2;
		}
		
		static P polar(double abs,double arg){
			return new P(abs*cos(arg),abs*sin(arg));
		}
		
		static P proj(P p,P o){
			return o.mul(new P(dot(p,o)/o.norm(),0));
		}
		public boolean equals(Object obj) {
			if(obj instanceof P){
				P p=(P)obj;
				return signum(x-p.x)==0 && signum(y-p.y)==0;
			}
			return false;
		}
		public String toString(){
			return "("+x+","+y+")";
		}
	}
	static class L extends AL{
		L(P _p1, P _p2) {super(_p1, _p2);}

		
		double dist(P p){
			return abs(P.S(p2,p,p1))/p1.sub(p2).norm();
		}
		boolean isIntersect(P p){
			return abs(P.S(p2,p,p1))<EPS;
		}
		boolean isIntersect(L l){
			if(isPoint() && l.isPoint())return p1.equals(l.p1);
			if(isPoint())return l.isIntersect(p1);
			if(l.isPoint())return isIntersect(l.p1);
			return !isParallel(l) || isIntersect(l.p1);
		}

		
		static P FootOfLP(L l,P p){
			return l.p1.add(P.proj(p.sub(l.p1),l.p2.sub(l.p1)));
		}

		
		static P LineSymmetricLP(L l,P p){
			return FootOfLP(l,p).mul(new P(2.0,0)).sub(p);
		}

		public boolean equals(Object obj) {
			if(obj instanceof L){
				L l=(L)obj;
				return isParallel(l) && isIntersect(l.p1);
			}
			return false;
		}
	}
	
	class S extends AL{
		S(P _p1, P _p2) {super(_p1, _p2);}
		boolean isIntersect(P p){
			return p1.sub(p).norm()+p2.sub(p).norm()<=p1.sub(p2).norm()+EPS;
		}
		boolean isIntersect(L l){
			return P.cross(l.p2.sub(l.p1),p1.sub(l.p1))*
				P.cross(l.p2.sub(l.p1),p2.sub(l.p1))<EPS;
		}
		boolean isIntersect(S l){
			return P.ccw(p1,p2,l.p1)*P.ccw(p1,p2,l.p2)<=0
			&& P.ccw(l.p1,l.p2,p1)*P.ccw(l.p1,l.p2,p2)<=0;
		}
		
		double dist(P p){
			if(P.dot(p2.sub(p1),p.sub(p1))<EPS)return p.sub(p1).norm();
			if(P.dot(p1.sub(p2),p.sub(p2))<EPS)return p.sub(p2).norm();
			return abs(P.S(p2,p,p1))/p1.sub(p2).norm();
		}
		
		double dist(L l){
			if(isIntersect(l))return 0;
			return min(l.dist(p1),l.dist(p2));
		}
		
		double dist(S l){
			if(isIntersect(l))return 0;
			return min(min(dist(l.p1),dist(l.p2)),min(l.dist(p1),l.dist(p2)));
		}
	}
	static abstract class AL{
		
			static final double EPS=1e-10;
			static int signum(double x){
				return x<-EPS?-1:x>EPS?1:0;
			}
		public P p1,p2;
		AL(P _p1,P _p2){
			p1=_p1;
			p2=_p2;
		}

		boolean isPoint(){
			return p1.equals(p2);
		}









		
		boolean isParallel(AL l){
			return abs(P.cross(p2.sub(p1),l.p2.sub(l.p1)))<EPS;
		}
		
		boolean isOrthogonal(AL l){
			return abs(P.dot(p2.sub(p1),l.p2.sub(l.p1)))<EPS;
		}

		
		static P intersection(AL l1,AL l2){
			P dl1=l1.p2.sub(l1.p1),dl2=l2.p2.sub(l2.p1);
			double a=P.cross(dl2,l2.p1.sub(l1.p1));
			double b=P.cross(dl2,dl1);
			if(abs(a)<EPS && abs(b) <EPS)return l1.p1;
			return l1.p1.add(dl1.mul(new P(a/b,0.0)));
		}


		public boolean equals(Object obj) {
			if(obj instanceof L){
				L l=(L)obj;
				return this.p1.equals(l.p1) && this.p2.equals(l.p2);
			}
			return false;
		}
		public String toString(){
			return p1+"-"+p2;
		}
	}
}