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;
const int MOD = 1000000007, dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
const double eps = 1e-8, pi = acos(-1);
void read(int &k) {
  k = 0;
  char x = getchar();
  while (x < '0' || x > '9') x = getchar();
  while (x >= '0' && x <= '9') {
    k = k * 10 - 48 + x;
    x = getchar();
  }
}
int cmp(double x, double y) {
  if (fabs(x - y) < eps) return 0;
  return x < y ? -1 : 1;
}
struct point {
  double x, y, z;
  point() { z = 1; }
  point(double xx, double yy, double zz) {
    x = xx;
    y = yy;
    z = zz;
  }
  double operator*(point b) { return x * b.x + y * b.y + z * b.z; }
  point operator*(double k) { return (point){k * x, k * y, z}; }
  point operator/(point b) {
    return (point){y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x};
  }
  point operator-(point b) { return (point){x - b.x, y - b.y, z}; }
  point operator+(point b) { return (point){x + b.x, y + b.y, z}; }
  void rotate(double theta) {
    point T = *this;
    x = T.x * cos(theta) - T.y * sin(theta);
    y = T.x * sin(theta) + T.y * cos(theta);
  }
  void output() { printf("%.9lf %.9lf ", x, y); }
  bool operator<(point b) const {
    int t = cmp(x, b.x);
    if (t == 0) return cmp(y, b.y) < 0;
    return t < 0;
  }
};
point V, P, WL, WR, ML, MR, dir, tP, tmp;
int inl(point x, point y, point z) { return cmp(x * (y / z), 0) == 0; }
point Normal(point y, point z) {
  point tmp = z - y;
  tmp.rotate(pi / 2);
  return tmp;
}
point Mirror(point x, point y, point z) {
  point nvec;
  nvec = Normal(y, z);
  point tmp = y / z, o, nxt;
  o = (point){tmp.y, -tmp.x, 0};
  o.z = -(x.x * o.x + x.y * o.y);
  nxt = o / tmp;
  nxt.x /= nxt.z;
  nxt.y /= nxt.z;
  nxt.z = 1;
  return nxt * 2 - x;
}
int in(point x, point y, point z) {
  int flag1 = 0, flag2 = 0;
  if (cmp(x.x, y.x) >= 0 && cmp(x.x, z.x) <= 0) flag1 = 1;
  if (cmp(x.x, z.x) >= 0 && cmp(x.x, y.x) <= 0) flag1 = 1;
  if (cmp(x.y, y.y) >= 0 && cmp(x.y, z.y) <= 0) flag2 = 1;
  if (cmp(x.y, z.y) >= 0 && cmp(x.y, y.y) <= 0) flag2 = 1;
  return flag1 & flag2;
}
int intersect(point x0, point y0, point x1, point y1, point &ret) {
  point l1, l2;
  l1 = x0 / y0;
  l2 = x1 / y1;
  ret = l1 / l2;
  if (cmp(ret.z, 0) == 0) return 0;
  ret.x /= ret.z;
  ret.y /= ret.z;
  ret.z = 1;
  return in(ret, x0, y0) && in(ret, x1, y1);
}
int cross(point x0, point y0, point x1, point y1) {
  if (inl(x1, x0, y0) && inl(y1, x0, y0))
    return in(x1, x0, y0) || in(y1, x0, y0) || in(x0, x1, y1) || in(y0, x1, y1);
  point a = y0 - x0;
  int flag1 = 0, flag2 = 0;
  if (cmp(((x1 - x0) / a).z * ((y1 - x0) / a).z, 0) <= 0) flag1 = 1;
  a = y1 - x1;
  if (cmp(((x0 - x1) / a).z * ((y0 - x1) / a).z, 0) <= 0) flag2 = 1;
  return flag1 & flag2;
}
int sgn(double x) { return cmp(x, 0); }
point midvectical(point x, point y) {
  point ret = x / y, z = (x + y) * 0.5;
  swap(ret.x, ret.y);
  ret.y = -ret.y;
  ret.z = -(z.x * ret.x + z.y * ret.y);
  return ret;
}
double dist(point a, point b) { return hypot(a.x - b.x, a.y - b.y); }
double ans, sum, tot;
point S, T, a[110], lis[10];
int cnt, n, sm, len;
int main() {
  scanf("%lf%lf%lf%lf", &S.x, &S.y, &T.x, &T.y);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lf%lf", &a[i].x, &a[i].y);
  a[n] = a[0];
  point las = (point){1000, 1000, 1};
  for (int i = 0; i < n; i++) {
    sum += dist(a[i + 1], a[i]);
    if (intersect(a[i], a[i + 1], S, T, tmp)) {
      if (tmp < las || las < tmp) {
        lis[++len] = tmp;
        if (!cnt)
          tot += dist(tmp, a[i + 1]);
        else
          tot += dist(a[i], tmp);
        cnt ^= 1;
        las = tmp;
        continue;
      }
    } else if (inl(a[i], S, T) && inl(a[i + 1], S, T))
      sm++;
    if (cnt) tot += dist(a[i], a[i + 1]);
  }
  if (len < 2 || sm) {
    printf("%.9lf\n", dist(S, T));
    return 0;
  }
  if (len >= 2) {
    sort(lis + 1, lis + len + 1);
    for (int i = 2; i <= len; i++)
      if (!(lis[i - 1] < lis[i]) && !(lis[i] < lis[i - 1])) {
        for (int j = i + 1; j <= len; j++) lis[j - 1] = lis[j];
        len--;
      }
    ans = 1e50;
    if (dist(lis[1], S) > dist(lis[2], S)) swap(lis[1], lis[2]);
    ans =
        min(dist(S, lis[1]) + 2 * dist(lis[1], lis[2]) + dist(lis[2], T), ans);
    ans = min(dist(lis[1], S) + dist(lis[2], T) + min(tot, sum - tot), ans);
    printf("%.9lf\n", ans);
    return 0;
  }
  while (1)
    ;
  return 0;
}