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;
const int N = 1001;
int cmp(double A) {
  if (fabs(A) < eps)
    return 0;
  else
    return A > 0 ? 1 : -1;
}
struct Point {
  double x, y;
  Point(double _x = 0.0, double _y = 0.0) : x(_x), y(_y) {}
  friend bool operator<(Point A, Point B) {
    return A.x < B.x || (A.x == B.x && A.y < B.y);
  }
  friend bool operator==(Point A, Point B) {
    return cmp(A.x - B.x) == 0 && cmp(A.y - B.y) == 0;
  }
  friend Point operator+(Point A, Point B) {
    return Point(A.x + B.x, A.y + B.y);
  }
  friend Point operator-(Point A, Point B) {
    return Point(A.x - B.x, A.y - B.y);
  }
  friend Point operator*(Point A, double k) { return Point(A.x * k, A.y * k); }
  friend double operator*(Point A, Point B) { return A.x * B.x + A.y * B.y; }
  friend double operator^(Point A, Point B) { return A.x * B.y - A.y * B.x; }
  void read() { scanf("%lf%lf", &x, &y); }
  void write() { printf("%lf %lf\n", x, y); }
  double dis() { return sqrt(x * x + y * y); }
} Convex_Hull[N], P[N], S, T;
struct Line {
  Point S, T;
  Line(Point _S = Point(0, 0), Point _T = Point(0, 0)) : S(_S), T(_T) {}
  friend bool Judge3(Line A, Line B) {
    if (cmp((A.T - A.S) ^ (B.T - B.S)) == 0) return false;
    return true;
  }
  friend bool Judge2(Line A, Line B) {
    if (cmp(((A.S - B.S) ^ (B.T - B.S)) * ((A.T - B.S) ^ (B.T - B.S))) > 0)
      return false;
    if (cmp(((B.S - A.S) ^ (A.T - A.S)) * ((B.T - A.S) ^ (A.T - A.S))) > 0)
      return false;
    return true;
  }
  friend bool Judge1(Line A, Line B) {
    if (min(A.S.x, A.T.x) > max(B.S.x, B.T.x)) return false;
    if (max(A.S.x, A.T.x) < min(B.S.x, B.T.x)) return false;
    if (min(A.S.y, A.T.y) > max(B.S.y, B.T.y)) return false;
    if (max(A.S.y, A.T.y) < min(B.S.y, B.T.y)) return false;
    return true;
  }
  friend bool Two_Segment_Intersect(Line A, Line B) {
    if (!Judge1(A, B)) return false;
    if (!Judge2(A, B)) return false;
    if (!Judge3(A, B)) return false;
    return true;
  }
  friend Point Two_Line_Intersect(Line A, Line B) {
    if (A.S == B.S || A.S == B.T) return A.S;
    if (A.T == B.S || A.T == B.T) return A.T;
    double k = ((B.T - A.T) ^ (A.S - A.T)) / ((A.T - A.S) ^ (B.T - B.S));
    return B.T + (B.S - B.T) * k;
  }
} L, C[N];
int n;
double All = 0;
double Fir = 0;
double Sec = 0;
double ans = 0;
int top = 0;
void Push(Point now) {
  while (top && ((P[top - 1] - P[top]) ^ (now - P[top - 1])) < 0 ||
         (P[top] == now))
    top--;
  P[++top] = now;
}
void Make_Convex_Hull() {
  sort(Convex_Hull + 1, Convex_Hull + 1 + n);
  P[0] = P[top = 1] = Convex_Hull[1];
  for (int i = 2; i <= n; ++i) Push(Convex_Hull[i]);
  for (int i = n - 1; i >= 2; --i) Push(Convex_Hull[i]);
  for (int i = 1; i <= top; ++i) Convex_Hull[i] = P[i];
}
bool Check() {
  Point A, B;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (Two_Segment_Intersect(L, C[i]) && cnt < 2) {
      cnt++;
      if (cnt == 1) {
        A = Two_Line_Intersect(L, C[i]);
        Sec += (C[i].T - A).dis();
      } else {
        B = Two_Line_Intersect(L, C[i]);
        if (cmp(A.x - B.x) == 0 && cmp(A.y - B.y) == 0) {
          Sec += (C[i].T - C[i].S).dis();
          cnt--;
          continue;
        }
        Sec += (C[i].S - B).dis();
      }
    } else {
      if (cnt == 1) {
        Sec += (C[i].T - C[i].S).dis();
      }
    }
  }
  if (cnt == 2) {
    Fir += min((S - A).dis(), (S - B).dis());
    Fir += min((T - A).dis(), (T - B).dis());
    ans = min((B - A).dis() * 2 + Fir, min(Sec, All - Sec) + Fir);
  }
  return cnt == 2;
}
int main() {
  S.read();
  T.read();
  L = Line(S, T);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    Convex_Hull[i].read();
  }
  Make_Convex_Hull();
  for (int i = 1; i < n; ++i) {
    C[i] = Line(Convex_Hull[i], Convex_Hull[i + 1]);
    All += (C[i].T - C[i].S).dis();
  }
  C[n] = Line(Convex_Hull[n], Convex_Hull[1]);
  All += (C[n].T - C[n].S).dis();
  if (!Check()) {
    cout << fixed << setprecision(7) << (T - S).dis();
  } else {
    cout << fixed << setprecision(7) << ans;
  }
  return 0;
}