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 a, b, f, g, h, i, j, l;
struct Point {
  double x, y;
  Point() {}
  Point(double x, double y) : x(x), y(y) {}
  friend Point operator+(const Point &x, const Point &y) {
    return Point(x.x + y.x, x.y + y.y);
  }
  friend Point operator-(const Point &x, const Point &y) {
    return Point(x.x - y.x, x.y - y.y);
  }
  friend Point operator*(const int &x, const Point &y) {
    return Point(x * y.x, x * y.y);
  }
};
struct Line {
  Point x, y;
};
double c, d, e;
Point q, z, G[105], ch[105];
Line H[105];
bool vv[106];
vector<Point> GG, F;
int E[5];
int ok;
double X(Point x, Point y) { return x.x * y.y - x.y * y.x; }
Point Jiao(Point P, Point v, Point Q, Point w) {
  Point u, T;
  double ii;
  u = P - Q;
  ii = X(w, u) / X(v, w);
  T = Point(ii * v.x, ii * v.y);
  return P + T;
}
bool In(Point x, Line y) {
  if ((x.x - y.x.x) * (x.x - y.y.x) < 1e-7 &&
      (x.y - y.x.y) * (x.y - y.y.y) < 1e-7 &&
      fabs(X(x - y.x, y.y - y.x)) < 1e-7)
    return true;
  return false;
}
bool Eq(Point x, Point y) {
  return fabs(x.x - y.x) <= 1e-7 && fabs(x.y - y.y) <= 1e-7;
}
double sq(double x) { return x * x; }
double D(Point x, Point y) { return sqrt(sq(x.x - y.x) + sq(x.y - y.y)); }
int main() {
  scanf("%lf%lf", &c, &d);
  q = Point(c, d);
  scanf("%lf%lf", &c, &d);
  z = Point(c, d);
  scanf("%d", &a);
  for (i = 1; i <= a; i++) {
    scanf("%lf%lf", &c, &d);
    G[i] = Point(c, d);
  }
  for (i = 1; i < a; i++) {
    H[i].x = G[i];
    H[i].y = G[i + 1];
  }
  H[a].x = G[a];
  H[a].y = G[1];
  H[0].x = q;
  H[0].y = z;
  for (i = 1; i <= a; i++) {
    j = i + 1;
    if (i == a) j = 1;
    if (In(G[i], H[0]) && In(G[j], H[0])) {
      printf("%.10lf\n", D(q, z));
      return 0;
    }
  }
  for (i = 1; i <= a; i++) {
    ch[1] = Jiao(H[0].x, H[0].y - H[0].x, H[i].x, H[i].y - H[i].x);
    if (In(ch[1], H[0]) && In(ch[1], H[i]) && (!Eq(ch[1], H[i].y))) {
      GG.push_back(ch[1]);
      E[++E[0]] = i;
    }
  }
  if (E[0] <= 1) {
    printf("%.10lf\n", D(q, z));
    return 0;
  }
  i = E[1] + 1;
  if (E[1] == a) i = 1;
  c = D(GG[0], G[i]);
  if (i == E[2]) c += D(G[E[2]], GG[1]);
  while (i != E[2]) {
    j = i + 1;
    if (i == a) j = 1;
    c += D(G[i], G[j]);
    if (j == E[2]) {
      c += D(G[E[2]], GG[1]);
      break;
    }
    i = j;
  }
  i = E[2] + 1;
  if (E[2] == a) i = 1;
  d = D(GG[1], G[i]);
  if (i == E[1]) d += D(G[E[1]], GG[0]);
  while (i != E[1]) {
    j = i + 1;
    if (i == a) j = 1;
    d += D(G[i], G[j]);
    if (j == E[1]) {
      d += D(G[E[1]], GG[0]);
      break;
    }
    i = j;
  }
  e = D(q, GG[0]) + D(GG[1], z);
  e = min(e, D(q, GG[1]) + D(GG[0], z));
  c = min(c, d) + e;
  e = e + 2 * D(GG[0], GG[1]);
  printf("%.10lf\n", min(c, e));
  return 0;
}