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;
struct point {
  double x, y;
  point() {}
  point(double a, double b) { x = a, y = b; }
  point(const point &p) { x = p.x, y = p.y; }
  double dist(const point &p) {
    return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
  }
};
point s;
struct line {
  point u, v;
  double a, b, c;
  line(point x, point y) {
    u.x = x.x;
    u.y = x.y;
    v.x = y.x;
    v.y = y.y;
    a = (u.y - v.y);
    b = (v.x - u.x);
    c = -b * u.y - a * u.x;
  }
  bool section(const line &l) {
    double a1 = l.a, b1 = l.b, c1 = l.c;
    if (a1 * b - a * b1 == 0) return false;
    double x, y;
    x = (c1 * b - c * b1) / (a * b1 - a1 * b);
    y = -(c * a1 - c1 * a) / (a1 * b - a * b1);
    double mxx = (u.x > v.x ? u.x : v.x), mnx = (u.x < v.x ? u.x : v.x);
    double mxy = (u.y > v.y ? u.y : v.y), mny = (u.y < v.y ? u.y : v.y);
    if (mnx <= x && x <= mxx && mny <= y && y <= mxy) {
      mxx = (l.u.x > l.v.x ? l.u.x : l.v.x),
      mnx = (l.u.x < l.v.x ? l.u.x : l.v.x);
      mxy = (l.u.y > l.v.y ? l.u.y : l.v.y),
      mny = (l.u.y < l.v.y ? l.u.y : l.v.y);
      if (mnx <= x && x <= mxx && mny <= y && y <= mxy) {
        s.x = x, s.y = y;
        return true;
      }
    }
    return false;
  }
};
vector<point> pt;
vector<line> v;
vector<point> sec;
vector<pair<int, int> > l;
double w[100][100];
int main() {
  double x, y;
  cin >> x >> y;
  point start(x, y);
  cin >> x >> y;
  point ed(x, y);
  int n;
  scanf("%d", &n);
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    pt.push_back(point(x, y));
  }
  for (i = 0; i < n + 4; i++) {
    for (j = 0; j < n + 4; j++) {
      w[i][j] = 1000000000.0;
    }
  }
  for (i = 0; i < n - 1; i++) {
    v.push_back(line(pt[i], pt[i + 1]));
    w[i][i + 1] = w[i + 1][i] = pt[i].dist(pt[i + 1]);
  }
  v.push_back(line(pt[n - 1], pt[0]));
  w[n - 1][0] = w[0][n - 1] = pt[0].dist(pt[n - 1]);
  line m(start, ed);
  for (i = 0; i < n; i++) {
    if (m.section(v[i])) {
      if (sec.size() >= 1) {
        if (sec[0].x == s.x && sec[0].y == s.y) continue;
        sec.push_back(point(s.x, s.y));
        l.push_back(make_pair(i, (i + 1) % n));
      } else {
        sec.push_back(point(s.x, s.y));
        l.push_back(make_pair(i, (i + 1) % n));
      }
    }
  }
  if (sec.size() <= 1) {
    printf("%.8lf\n", start.dist(ed));
  } else {
    double p, q;
    p = start.dist(sec[0]);
    q = start.dist(sec[1]);
    if (p < q) {
      w[n + 2][n] = w[n][n + 2] = start.dist(sec[0]);
      w[n + 3][n + 1] = w[n + 1][n + 3] = ed.dist(sec[1]);
      w[n][l[0].first] = w[l[0].first][n] = sec[0].dist(pt[l[0].first]);
      w[n][l[0].second] = w[l[0].second][n] = sec[0].dist(pt[l[0].second]);
      w[n + 1][l[1].first] = w[l[1].first][n + 1] = sec[1].dist(pt[l[1].first]);
      w[n + 1][l[1].second] = w[l[1].second][n + 1] =
          sec[1].dist(pt[l[1].second]);
    } else {
      swap(sec[0], sec[1]);
      swap(l[0], l[1]);
      w[n + 2][n] = w[n][n + 2] = start.dist(sec[0]);
      w[n + 3][n + 1] = w[n + 1][n + 3] = ed.dist(sec[1]);
      w[n][l[0].first] = w[l[0].first][n] = sec[0].dist(pt[l[0].first]);
      w[n][l[0].second] = w[l[0].second][n] = sec[0].dist(pt[l[0].second]);
      w[n + 1][l[1].first] = w[l[1].first][n + 1] = sec[1].dist(pt[l[1].first]);
      w[n + 1][l[1].second] = w[l[1].second][n + 1] =
          sec[1].dist(pt[l[1].second]);
    }
    w[n][n + 1] = w[n + 1][n] = 2.0 * sec[0].dist(sec[1]);
    int i, j, k;
    for (k = 0; k <= n + 3; k++) {
      for (i = 0; i <= n + 3; i++) {
        for (j = 0; j <= n + 3; j++) {
          w[i][j] = (w[i][j] < w[i][k] + w[k][j] ? w[i][j] : w[i][k] + w[k][j]);
        }
      }
    }
    printf("%.8lf\n", w[n + 2][n + 3]);
  }
}