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;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
const double EPS = (1e-9);
const long long int INF = 1e18;
const int M = (1e9) + 7;
const int N = 200;
struct Point {
  double x, y;
  Point(double a = 0, double b = 0) { x = a, y = b; }
  void reassign(double a, double b) { x = a, y = b; }
  void input() { cin >> x >> y; }
  void print() { cout << x << " " << y << endl; }
  Point operator+=(Point A) {
    x += A.x, y += A.y;
    return *this;
  }
  Point operator-=(Point A) {
    x -= A.x, y -= A.y;
    return *this;
  }
  Point operator+(Point A) {
    Point tp(x + A.x, y + A.y);
    return tp;
  }
  Point operator-(Point A) {
    Point tp(x - A.x, y - A.y);
    return tp;
  }
  Point operator*(double f) {
    Point tp(x * f, y * f);
    return tp;
  }
  Point operator/(double f) {
    Point tp(x / f, y / f);
    return tp;
  }
  Point operator*=(double f) {
    x *= f, y *= f;
    return *this;
  }
  Point operator/=(double f) {
    x /= f, y /= f;
    return *this;
  }
  bool operator==(Point A) {
    if (x == A.x && y == A.y) return true;
    return false;
  }
  bool operator!=(Point A) {
    if (x != A.x || y != A.y) return true;
    return false;
  }
  void ulta() { swap(x, y); }
};
Point makepoint(double a, double b) {
  Point temp(a, b);
  return temp;
}
void swap(Point &A, Point &B) {
  swap(A.x, B.x);
  swap(A.y, B.y);
}
bool cmp(Point a, Point b) {
  if (a.x != b.x) return (a.x < b.x);
  return (a.y < b.y);
}
long double dotproduct(Point a, Point b) { return a.x * b.x + a.y * b.y; }
long double crossproduct(Point a, Point b) { return a.x * b.y - a.y * b.x; }
int ccw(Point a, Point b, Point origin = makepoint(0, 0)) {
  long double x = crossproduct(a - origin, b - origin);
  if (x > EPS) return 1;
  if (x < EPS) return -1;
  return 0;
}
long double sqrdist(Point a, Point b = makepoint(0, 0)) {
  long double q = 0, temp;
  temp = a.x - b.x;
  temp *= temp, q += temp;
  temp = a.y - b.y;
  temp *= temp, q += temp;
  return q;
}
double dist(Point a, Point b = makepoint(0, 0)) {
  long double temp = sqrdist(a, b);
  return sqrt(temp);
}
double anglepolar(Point a) { return atan2(a.y, a.x); }
double anglebetween(Point a, Point b, Point origin = makepoint(0, 0)) {
  return atan2(crossproduct(a - origin, b - origin),
               dotproduct(a - origin, b - origin));
}
Point perp(Point a) { return makepoint(-a.y, a.x); }
Point bisector(Point a, Point b) {
  Point res;
  res = a * dist(b) + b * dist(a);
  return res;
}
struct Line {
  Point a, b, ab;
  bool isline;
  Line() {
    a = makepoint(0, 0);
    b = a, ab = a, isline = 0;
  }
  Line(Point p, Point q) {
    a = p, b = q;
    ab = b - a;
    if (a != b)
      isline = 1;
    else
      isline = 0;
  }
  void update(Point p, Point q) {
    a = p, b = q;
    ab = b - a;
    if (a != b)
      isline = 1;
    else
      isline = 0;
    return;
  }
  bool operator==(Line other) {
    return ((crossproduct(ab, other.ab) == 0) && online(other.a));
  }
  bool online(Point point) {
    if (!isline) return (point == a);
    return (crossproduct(point - a, ab) == 0);
  }
  bool onsegment(Point point) {
    if (!isline) return (point == a);
    Point va, vb;
    va = a - point, vb = b - point;
    return (dotproduct(va, vb) <= 0);
  }
  bool parallel(Line other) { return (crossproduct(ab, other.ab) == 0); }
  bool perpendicular(Line other) { return (dotproduct(ab, other.ab) == 0); }
  double distline(Point point) {
    if (!isline) return dist(a, point);
    long double t = abs(crossproduct(point - a, ab));
    t /= dist(ab);
    return t;
  }
  double distsegment(Point point) {
    if (dotproduct(point - a, ab) <= 0) return dist(a, point);
    if (dotproduct(point - b, ab) >= 0) return dist(b, point);
    return distline(point);
  }
  Point projection(Point point) {
    Point res;
    if (isline) res = (ab * dotproduct(point - a, ab)) / sqrdist(ab);
    return res + a;
  }
  Point reflection(Point point) {
    Point res = projection(point);
    res *= 2, res -= point;
    return res;
  }
  Point closest(Point point) {
    if (dotproduct(point - a, ab) <= 0) return a;
    if (dotproduct(point - b, ab) >= 0) return b;
    return projection(point);
  }
  bool lineintersectcheck(Line ray) { return (crossproduct(ab, ray.ab) != 0); }
  bool inter1(int a, int b, int c, int d) {
    if (a > b) swap(a, b);
    if (c > d) swap(c, d);
    return max(a, c) <= min(b, d);
  }
  bool segmentintersectcheck(Line ray) {
    if (crossproduct(ab, ray.ab) == 0) {
      if (online(ray.a))
        return inter1(a.x, b.x, ray.a.x, ray.b.x) &&
               inter1(a.y, b.y, ray.a.y, ray.b.y);
      return false;
    }
    return (crossproduct(ray.a - a, ray.a - b) !=
            crossproduct(ray.b - a, ray.b - b)) &&
           (crossproduct(a - ray.a, a - ray.b) !=
            crossproduct(b - ray.a, b - ray.b));
  }
  Point intersectionpoint(Line ray) {
    double d = crossproduct(ray.a - a, ray.ab);
    d /= crossproduct(ab, ray.ab);
    Point temp;
    temp = ab, temp *= d, temp += a;
    return temp;
  }
};
Point v[N];
double ad[N][N];
void makeit(int a, int b, double c) {
  ad[a][b] = c;
  ad[b][a] = c;
  return;
}
double dis[N];
int vis[N];
void dijkstra(int s, int n) {
  fill(dis, dis + n, INF);
  fill(vis, vis + n, 0);
  dis[s] = 0;
  int i, j;
  for (i = 0; i < n; ++i) {
    s = -1;
    for (j = 0; j < n; ++j) {
      if (!vis[j] && (s == -1 || dis[j] < dis[s])) s = j;
    }
    if (dis[s] == INF) break;
    vis[s] = 1;
    for (j = 0; j < n; ++j) {
      if (dis[j] > dis[s] + ad[s][j]) dis[j] = dis[s] + ad[s][j];
    }
  }
  return;
}
int main() {
  int n, i, j, k, a;
  Point sr, des;
  sr.input();
  des.input();
  scanf("%d", &n);
  Line ray(sr, des);
  for (i = 1; i <= n; i++) v[i].input();
  a = 0;
  cout << setprecision(12) << fixed;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) makeit(i, j, 2 * dist(v[i], v[j]));
  }
  Point one, two;
  one.reassign(-N, -N);
  two.reassign(-N, -N);
  for (i = 1; i <= n; i++) {
    j = (i < n ? i + 1 : 1);
    makeit(i, j, dist(v[i], v[j]));
    if (ccw(sr, des, v[i]) != ccw(sr, des, v[j])) {
      Line temp(v[i], v[j]);
      v[a] = ray.intersectionpoint(temp);
      if (!ray.onsegment(v[a])) continue;
      if (a > 0 && (v[a] == one || v[a] == two)) continue;
      for (k = 1; k <= n; k++) makeit(a, k, 2 * dist(v[a], v[k]));
      makeit(a, i, dist(v[a], v[i]));
      makeit(a, j, dist(v[a], v[j]));
      if (a == 0)
        one = v[a];
      else
        two = v[a];
      a += (n + 1);
    }
  }
  {
    string _s = "a";
    replace(_s.begin(), _s.end(), ',', ' ');
    stringstream _ss(_s);
    istream_iterator<string> _it(_ss);
    err(_it, a);
  };
  if (a == 0) cout << dist(sr, des) << "\n", exit(0);
  if (dist(sr, v[n + 1]) < dist(sr, v[0])) swap(sr, des);
  makeit(0, n + 1, 2 * dist(v[0], v[n + 1]));
  dijkstra(0, n + 2);
  double ans;
  ans = dist(sr, v[0]) + dist(v[n + 1], des) + dis[n + 1];
  cout << ans << "\n";
}