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 double eps = 1e-8;
struct point {
  double x, y;
  point(double _x = 0, double _y = 0) : x(_x), y(_y) {}
  void read() { scanf("%lf%lf", &x, &y); }
};
point polygon[30];
int sign(double x) {
  if (fabs(x) < eps) return 0;
  return (x > 0) ? 1 : -1;
}
double cross(const point &a, const point &b, const point &c, const point &d) {
  return (b.x - a.x) * (d.y - c.y) - (b.y - a.y) * (d.x - c.x);
}
double dist(const point &a, const point &b) {
  return hypot(a.x - b.x, a.y - b.y);
}
pair<point, bool> getIntersection(const point &a, const point &b,
                                  const point &c, const point &d) {
  if (sign(cross(a, b, c, d)) == 0) return make_pair(point(0, 0), false);
  double a1 = b.x - a.x, b1 = c.x - d.x, c1 = c.x - a.x;
  double a2 = b.y - a.y, b2 = c.y - d.y, c2 = c.y - a.y;
  double tmp = a1 * b2 - a2 * b1;
  double x = (c1 * b2 - c2 * b1) / tmp;
  double y = (c2 * a1 - c1 * a2) / tmp;
  if (sign(x) >= 0 && sign(x - 1) < 0 && sign(y) >= 0 && sign(y - 1) < 0) {
    return make_pair(point(a.x + x * (b.x - a.x), a.y + x * (b.y - a.y)), true);
  } else {
    return make_pair(point(0, 0), false);
  }
}
int main() {
  point start, end;
  start.read();
  end.read();
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) polygon[i].read();
  int flag = 0;
  point a, b;
  int la, lb;
  for (int i = 0; i < n; i++) {
    pair<point, bool> tmp =
        getIntersection(start, end, polygon[i], polygon[(i + 1) % n]);
    if (tmp.second) {
      if (flag == 0) {
        a = tmp.first;
        la = i;
      } else {
        b = tmp.first;
        lb = i;
      }
      flag++;
    }
  }
  if (flag < 2) {
    printf("%.10lf\n", dist(start, end));
    return 0;
  }
  if (sign(dist(start, a) - dist(start, b)) > 0) {
    swap(a, b);
    swap(la, lb);
  }
  double ans = dist(start, a) + dist(a, b) * 2 + dist(b, end);
  double s1 = dist(start, a) + dist(a, polygon[(la + 1) % n]);
  for (int i = (la + 1) % n; i != lb; i = (i + 1) % n)
    s1 += dist(polygon[i], polygon[(i + 1) % n]);
  s1 += dist(polygon[lb], b) + dist(b, end);
  ans = min(ans, s1);
  double s2 = dist(start, a) + dist(a, polygon[la]);
  for (int i = la; i != (lb + 1) % n; i = (i + n - 1) % n)
    s2 += dist(polygon[i], polygon[(i + n - 1) % n]);
  s2 += dist(polygon[(lb + 1) % n], b) + dist(b, end);
  ans = min(ans, s2);
  printf("%.10lf\n", ans);
  return 0;
}