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;
template <class A, class B>
A convert(B x) {
  stringstream s;
  s << x;
  A r;
  s >> r;
  return r;
}
pair<double, double> st, fn;
vector<pair<double, double> > p, po;
double d[33][33];
int n;
double Dist(pair<double, double> p1, pair<double, double> p2) {
  return sqrt(((p1.first - p2.first) * (p1.first - p2.first)) +
              ((p1.second - p2.second) * (p1.second - p2.second)));
}
int Sign(double a) {
  if (abs(a) < 1e-9) return 0;
  if (a > 0) return +1;
  if (a < 0) return -1;
}
void getABC(pair<double, double> p1, pair<double, double> p2, double& a,
            double& b, double& c) {
  a = p2.second - p1.second;
  b = p1.first - p2.first;
  c = -a * p1.first - b * p1.second;
}
bool SegmLineIntersect(pair<double, double> s11, pair<double, double> s12,
                       pair<double, double> s21, pair<double, double> s22) {
  double a, b, c;
  getABC(s11, s12, a, b, c);
  return Sign(a * s21.first + b * s21.second + c) *
             Sign(a * s22.first + b * s22.second + c) <
         0;
}
bool SegmSegmIntersect(pair<double, double> s11, pair<double, double> s12,
                       pair<double, double> s21, pair<double, double> s22) {
  return SegmLineIntersect(s11, s12, s21, s22) &&
         SegmLineIntersect(s21, s22, s11, s12);
}
pair<double, double> getLineLineIntersect(pair<double, double> s11,
                                          pair<double, double> s12,
                                          pair<double, double> s21,
                                          pair<double, double> s22) {
  double A1, B1, C1;
  getABC(s11, s12, A1, B1, C1);
  double A2, B2, C2;
  getABC(s21, s22, A2, B2, C2);
  double det = A1 * B2 - A2 * B1;
  pair<double, double> res =
      make_pair((B1 * C2 - B2 * C1) / det, (A1 * C2 - A2 * C1) / -det);
  return res;
}
bool Eq(pair<double, double> p1, pair<double, double> p2) {
  return abs(p1.first - p2.first) < 1e-8 && abs(p1.second - p2.second) < 1e-8;
}
bool Can(pair<double, double> ot, pair<double, double> ku) {
  for (int i = (0), _b(((int)(po).size())); i < _b; ++i)
    for (int j = (i + 1), _b(((int)(po).size())); j < _b; ++j)
      if (SegmSegmIntersect(ot, ku, po[i], po[j])) return false;
  return true;
}
bool isOn(pair<double, double> p1, pair<double, double> p2,
          pair<double, double> p) {
  double a, b, c;
  getABC(p1, p2, a, b, c);
  return !Sign(a * p.first + b * p.second + c);
}
int main() {
  cin >> st.first >> st.second;
  cin >> fn.first >> fn.second;
  cin >> n;
  p.resize(n);
  for (int i = (0), _b(n); i < _b; ++i) cin >> p[i].first >> p[i].second;
  for (int i = (n)-1, _a(0); i >= _a; --i) {
    pair<double, double> p1 = p[i];
    pair<double, double> p2 = p[(i + 1) % ((int)(p).size())];
    pair<double, double> res((p1.first + p2.first) / 2.,
                             (p1.second + p2.second) / 2.);
    p.insert(p.begin() + i + 1, res);
  }
  po = p;
  n = ((int)(p).size());
  if (Can(st, fn)) {
    printf("%.8lf\n", Dist(st, fn));
    return 0;
  }
  for (int i = (n)-1, _a(0); i >= _a; --i) {
    if (SegmSegmIntersect(st, fn, p[i], p[(i + 1) % n]))
      p.insert(p.begin() + i + 1,
               getLineLineIntersect(st, fn, p[i], p[(i + 1) % n]));
  }
  n = ((int)(p).size());
  for (int i = (0), _b(n); i < _b; ++i)
    for (int j = (0), _b(n); j < _b; ++j)
      if (i == j)
        d[i][j] = 0;
      else if (abs(i - j) == 1 || (i == 0 && j == n - 1) ||
               (i == n - 1 && j == 0))
        d[i][j] = Dist(p[i], p[j]);
      else
        d[i][j] = 2. * Dist(p[i], p[j]);
  for (int ch = (0), _b(n); ch < _b; ++ch)
    for (int ot = (0), _b(n); ot < _b; ++ot)
      for (int ku = (0), _b(n); ku < _b; ++ku)
        d[ot][ku] = min(d[ot][ku], d[ot][ch] + d[ch][ku]);
  double res = 1e20;
  for (int i = (0), _b(n); i < _b; ++i)
    if (Can(st, p[i]) && isOn(st, fn, p[i]))
      for (int j = (0), _b(n); j < _b; ++j)
        if (Can(p[j], fn) && isOn(st, fn, p[j]))
          res = min(res, Dist(st, p[i]) + d[i][j] + Dist(p[j], fn));
  cout << fixed << setprecision(10) << res << endl;
  return 0;
}