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 java.util.Scanner;

public class ShipShortestPath {

    static class Line {
        double a, b, c, x1, x2, y1, y2;

        public Line(double x1, double y1, double x2, double y2) {
            this.x1 = x1;
            this.y1 = y1;
            this.x2 = x2;
            this.y2 = y2;
            a = -1 * (y2 - y1);
            b = (x2 - x1);
            c = y1 * (x2 - x1) - x1 * (y2 - y1);
        }
        public double getLength() {
            return Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
        }
    }

    static class Point {
        double x, y;

        public Point(double xx, double yy) {
            x = xx;
            y = yy;
        }
    }

    public static Point intersect(Line i, Line j) {
        double det = i.a * j.b - i.b * j.a;
        if (det == 0)
            return null;
        double xin = j.b * i.c - i.b * j.c;
        xin = xin / det;
        double yin = i.a * j.c - i.c * j.a;
        yin = yin / det;
        //System.out.println(yin+" "+xin);
        if (xin <= Math.max(i.x1, i.x2) && xin >= Math.min(i.x1, i.x2)
                && xin <= Math.max(j.x1, j.x2) && xin >= Math.min(j.x1, j.x2))
            if (yin <= Math.max(i.y1, i.y2) && yin >= Math.min(i.y1, i.y2)
                    && yin <= Math.max(j.y1, j.y2)
                    && yin >= Math.min(j.y1, j.y2))
                return new Point(xin, yin);
        return null;
    }
    public static boolean equal(Point x,Point y) {
        if(Math.abs(x.x-y.x)<1e-7&&Math.abs(x.y-y.y)<1e-7) return true;
        return false;
    }
    public static  double getDist(Point a ,Point b) {
        return Math.sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double sx, sy, ex, ey;
        
        sx = sc.nextDouble();
        sy = sc.nextDouble();
        ex = sc.nextDouble();
        ey = sc.nextDouble();
        Line trip=new Line(sx, sy, ex, ey);
        //System.out.println(trip.a+" "+trip.b+" "+trip.c);
        Point s=new Point(sx,sy);
        Point e=new Point(ex,ey);
        int n = sc.nextInt();
        double x1 = sc.nextDouble(), y1 = sc.nextDouble(), x2, y2, x11 = x1, y11 = y1;
        Line[] Poly = new Line[n];
        for (int i = 0; i < n - 1; i++) {
            x2 = sc.nextDouble();
            y2 = sc.nextDouble();
            Poly[i] = new Line(x1, y1, x2, y2);
            x1 = x2;
            y1 = y2;
        }
        Poly[n - 1] = new Line(x1, y1, x11, y11);
        Point int1=null,int2=null;
        int i=0;
        int f=0,se=0;
        for(;i<n;i++) {
            Point t=intersect(trip, Poly[i]);
            if(t==null) continue;
            else {
                //System.out.println(t.x);
                int1=t; f=i;break;
                
            }
        }
        if(int1!=null) {
            for(;i<n;i++) {
                Point t=intersect(trip, Poly[i]);
                if(t==null) continue;
                else {
                    if(equal(t, int1)) continue;
                    int2=t; se=i;break;
                }
            }
            if(int2!=null) {
                //System.out.println(int1.x+" "+int1.y+"\n "+int2.x+" "+int2.y);
                double a1=0,a2=0;
                //System.out.println(f+" das "+se);
                for(int j=f+1;j<se;j++) a1+=Poly[j].getLength();
                //System.out.println(a1);
                a1+=getDist(int1, new Point(Poly[f+1].x1, Poly[f+1].y1))+
                getDist(int2, new Point(Poly[se].x1, Poly[se].y1));
                a2+=getDist(int1, new Point(Poly[(f-1+n)%n].x2, Poly[(f-1+n)%n].y2));
                for(int j=(se+1)%n;j!=f;j=(j+1)%n) a2+=Poly[j].getLength();
                //System.out.println(getDist(int1, new Point(Poly[(f-1+n)%n].x2, Poly[(f-1+n)%n].y2))+" "+getDist(int2, new Point(Poly[(se+1)%n].x1, Poly[(se+1)%n].y1)));
                a2+=getDist(int2, new Point(Poly[(se+1)%n].x1, Poly[(se+1)%n].y1));
                double t1,t2,t3;
                if(getDist(s, int1)<getDist(s, int2)) {
                    t1=getDist(s, int1)+getDist(int1, int2)*2+getDist(int2, e);
                    t2=getDist(s, int1)+a1+getDist(int2, e);
                    t3=getDist(s, int1)+a2+getDist(int2, e);
                }
                else {
                    t1=getDist(s, int2)+getDist(int2, int1)*2+getDist(int1, e);
                    t2=getDist(s, int2)+a1+getDist(int1, e);
                    t3=getDist(s, int2)+a2+getDist(int1, e);
                }
                //System.out.println(t1+" "+t2+" "+t3+" "+a1+" "+a2);
                System.out.println(Math.min(Math.min(t1, t2), t3)); return;
                
            }
        }
        System.out.println(trip.getLength()*1);
        
    }
}