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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int X[40];
int Y[40];
double gx, gy;
int indic;
bool inside(double x, int a, int b) {
  int ma = min(a, b);
  int Ma = max(a, b);
  if (x >= ma && x <= Ma) return true;
  return false;
}
void getIntersection(int x11, int y11, int x12, int y12, int x21, int y21,
                     int x22, int y22) {
  indic = 0;
  int B1 = x11 - x12;
  int A1 = y12 - y11;
  int C1 = A1 * (x11) + B1 * (y11);
  int B2 = x21 - x22;
  int A2 = y22 - y21;
  int C2 = A2 * (x21) + B2 * (y21);
  int D = A1 * B2 - A2 * B1;
  int Dx = C1 * B2 - C2 * B1;
  int Dy = A1 * C2 - A2 * C1;
  if (D == 0) {
    if (Dx != 0 || Dy != 0) {
      indic = 1;
    } else {
      indic = 2;
    }
  } else {
    gx = (double)Dx / D;
    gy = (double)Dy / D;
    if (!inside(gx, x11, x12) || !inside(gx, x21, x22) ||
        !inside(gy, y11, y12) || !inside(gy, y21, y22)) {
      indic = 1;
    }
  }
}
double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
vector<int> indxs;
vector<int> tindxs;
vector<double> pX;
vector<double> pY;
vector<double> tX;
vector<double> tY;
int main() {
  int xStart, yStart, xEnd, yEnd;
  scanf("%d%d%d%d", &xStart, &yStart, &xEnd, &yEnd);
  int n;
  double tDist = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", X + i, Y + i);
  }
  bool slid = false;
  for (int i = 0; i < n; i++) {
    int j = (i + 1) % n;
    getIntersection(X[i], Y[i], X[j], Y[j], xStart, yStart, xEnd, yEnd);
    tDist += dist(X[i], Y[i], X[j], Y[j]);
    if (indic == 2) {
      slid = true;
      break;
    } else if (indic == 1)
      continue;
    else {
      tindxs.push_back(i);
      tX.push_back(gx);
      tY.push_back(gy);
    }
  }
  for (int i = 0; i < tX.size(); i++) {
    int j = (i + 1) % tX.size();
    int pj = i;
    if (fabs(tX[j] - tX[pj]) <= 1e-9 && fabs(tY[j] - tY[pj]) <= 1e-9) {
      if (i == tX.size() - 1) break;
      i = j;
    }
    indxs.push_back(tindxs[i]);
    pX.push_back(tX[i]);
    pY.push_back(tY[i]);
  }
  if (slid == true || pX.size() <= 1) {
    printf("%.10lf\n", dist(xStart, yStart, xEnd, yEnd));
  } else {
    assert(pX.size() == 2);
    double take = dist(xStart, yStart, xEnd, yEnd);
    take += dist(pX[0], pY[0], pX[1], pY[1]);
    double fDist = 0;
    for (int j = indxs[0] + 1; j != indxs[1]; j = (j + 1) % n) {
      int k = (1 + j) % n;
      fDist += dist(X[j], Y[j], X[k], Y[k]);
    }
    fDist += dist(pX[0], pY[0], X[(1 + indxs[0]) % n], Y[(1 + indxs[0]) % n]);
    fDist += dist(pX[1], pY[1], X[(indxs[1]) % n], Y[(indxs[1]) % n]);
    fDist = min(fDist, tDist - fDist);
    fDist += min(dist(pX[0], pY[0], xStart, yStart),
                 dist(pX[1], pY[1], xStart, yStart));
    fDist +=
        min(dist(pX[0], pY[0], xEnd, yEnd), dist(pX[1], pY[1], xEnd, yEnd));
    fDist = min(fDist, take);
    printf("%.10lf\n", fDist);
  }
  return 0;
}