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 oo = 1047483647, maxn = 310;
const double eps = 1e-9;
int n, i, j, k, m, q, b[40], tot;
double best;
pair<double, double> a[40], S, E;
pair<double, double> r[40];
struct node {
  int w;
  pair<double, double> r;
} br[40];
double cha(pair<double, double> a, pair<double, double> b,
           pair<double, double> c) {
  double x1 = b.first - a.first, x2 = c.first - a.first;
  double y1 = b.second - a.second, y2 = c.second - a.second;
  return x1 * y2 - x2 * y1;
}
bool ok(pair<double, double> a, pair<double, double> b, pair<double, double> c,
        pair<double, double> d) {
  return cha(a, b, c) * cha(a, b, d) < eps;
}
bool getcross(pair<double, double> a, pair<double, double> b,
              pair<double, double> c, pair<double, double> d) {
  return (ok(a, b, c, d) && ok(c, d, a, b));
}
void solve() {
  for (i = 0; i <= n - 1; i++) {
    if (getcross(S, E, a[i], a[(i + 1) % n])) {
      br[++tot].w = i;
      double k =
          (double)cha(S, a[i], a[(i + 1) % n]) / cha(E, a[i], a[(i + 1) % n]);
      k = fabs(k);
      k = k / (1 + k);
      br[tot].r = make_pair(S.first + (E.first - S.first) * k,
                            S.second + (E.second - S.second) * k);
    }
  }
}
double dis(pair<double, double> a, pair<double, double> b) {
  return sqrt(((a.first - b.first) * (a.first - b.first)) +
              ((a.second - b.second) * (a.second - b.second)));
}
int ne(int x) { return (x + 1) % n; }
int pre(int x) { return (x - 1 + n) % n; }
bool cmp(const node& a, const node& b) {
  return (a.r.first < b.r.first) ||
         (a.r.first == b.r.first && a.r.second < b.r.second);
}
int main() {
  scanf("%lf%lf%lf%lf", &S.first, &S.second, &E.first, &E.second);
  scanf("%d", &n);
  for (i = 0; i <= n - 1; i++) {
    scanf("%lf%lf", &a[i].first, &a[i].second);
  }
  solve();
  sort(br + 1, br + tot + 1, cmp);
  int tt = tot;
  tot = 1;
  for (i = 2; i <= tt; i++) {
    if (fabs(br[i].r.first - br[i - 1].r.first) > eps ||
        fabs(br[i].r.second != br[i - 1].r.second) > eps)
      tot++;
    br[tot] = br[i];
  }
  if (tot != 2)
    printf("%.10f", dis(S, E));
  else {
    b[1] = br[1].w;
    r[1] = br[1].r;
    b[2] = br[2].w;
    r[2] = br[2].r;
    if (dis(S, r[1]) > dis(S, r[2])) {
      swap(r[1], r[2]);
      swap(b[1], b[2]);
    }
    best = dis(S, r[1]) + dis(r[1], r[2]) * 2 + dis(r[2], E);
    double tmp = dis(a[ne(b[1])], r[1]) + dis(a[b[2]], r[2]) + dis(S, r[1]) +
                 dis(r[2], E);
    for (i = ne(b[1]); i != b[2]; i = ne(i)) tmp += dis(a[i], a[ne(i)]);
    best = min(best, tmp);
    tmp = dis(a[b[1]], r[1]) + dis(r[2], a[ne(b[2])]) + dis(S, r[1]) +
          dis(r[2], E);
    for (i = b[1]; i != ne(b[2]); i = pre(i)) tmp += dis(a[i], a[pre(i)]);
    best = min(best, tmp);
    printf("%.9f", best);
  }
  return 0;
}