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>
const int N = 2500;
using namespace std;
struct pt {
  double x;
  double y;
};
struct seg {
  pt p1;
  pt p2;
};
int n;
pt island[N];
pt start;
pt finish;
double get_dist(pt a, pt b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
pt eval(pt a, pt b, double r) {
  a.x += (b.x - a.x) * r;
  a.y += (b.y - a.y) * r;
  return a;
}
double get_dist(pt p, seg s) {
  double l, r;
  l = 0;
  r = 1;
  for (int iter = 1; iter <= 100; iter++) {
    double mid1, mid2;
    mid1 = l * 2 + r;
    mid2 = l + r * 2;
    mid1 /= 3;
    mid2 /= 3;
    pt p1, p2;
    p1 = eval(s.p1, s.p2, mid1);
    p2 = eval(s.p1, s.p2, mid2);
    double d1, d2;
    d1 = get_dist(p, p1);
    d2 = get_dist(p, p2);
    if (d1 < d2)
      r = mid2;
    else
      l = mid1;
  }
  pt p1 = eval(s.p1, s.p2, l);
  return get_dist(p, p1);
}
double get_oriented_area(pt a, pt b, pt c) {
  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}
bool is_inside(pt p) {
  for (int i = 0; i < n; i++) {
    double A = get_oriented_area(island[i], island[(i + 1) % n], p);
    if (A < 0) return false;
  }
  return true;
}
double get_p_dist(pt p) {
  double res = 1e18;
  for (int i = 0; i < n; i++) {
    seg s;
    s.p1 = island[i];
    s.p2 = island[(i + 1) % n];
    res = min(res, get_dist(p, s));
  }
  if (is_inside(p)) return -res;
  return res;
}
double distance_shoreline(double a, double b, double L) {
  a = fabs(a - b);
  return min(a, L - a);
}
pt get_p_intersection(pt start, pt goal) {
  double l, r;
  l = 0;
  r = 1;
  for (int iter = 0; iter <= 100; iter++) {
    double mid = l + r;
    mid /= 2;
    pt temp = eval(start, goal, mid);
    if (is_inside(temp))
      r = mid;
    else
      l = mid;
  }
  pt temp = eval(start, goal, l);
  return temp;
}
double get_ang_pos(pt p) {
  double res = 0;
  for (int i = 0; i < n; i++) {
    double D = get_dist(island[i], island[(i + 1) % n]);
    double d1 = get_dist(island[i], p);
    double d2 = get_dist(island[(i + 1) % n], p);
    if (fabs(d1 + d2 - D) < 1e-8) return res + d1;
    res += D;
  }
}
void show(pt p) { cout << "%" << p.x << " " << p.y << endl; }
int main() {
  ios_base::sync_with_stdio(0);
  cin >> start.x >> start.y >> finish.x >> finish.y;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> island[i].x >> island[i].y;
  }
  double l, r;
  l = 0;
  r = 1;
  for (int iter = 1; iter <= 100; iter++) {
    double mid1 = l * 2 + r;
    double mid2 = l + r * 2;
    mid1 /= 3;
    mid2 /= 3;
    double dist1 = get_p_dist(eval(start, finish, mid1));
    double dist2 = get_p_dist(eval(start, finish, mid2));
    if (dist1 < dist2)
      r = mid2;
    else
      l = mid1;
  }
  pt P = eval(start, finish, l);
  double d = get_p_dist(P);
  if (d > 1e-8) {
    cout.precision(10);
    cout << fixed << get_dist(start, finish) << endl;
    return 0;
  }
  pt p1 = get_p_intersection(start, P);
  pt p2 = get_p_intersection(finish, P);
  double ans1 =
      get_dist(start, p1) + 2 * get_dist(p1, p2) + get_dist(p2, finish);
  double per = 0;
  for (int i = 0; i < n; i++) per += get_dist(island[i], island[(i + 1) % n]);
  double d1 = get_ang_pos(p1);
  double d2 = get_ang_pos(p2);
  double shoreline = distance_shoreline(d1, d2, per);
  double ans2 = get_dist(start, p1) + get_dist(finish, p2) + shoreline;
  cout << fixed << min(ans1, ans2) << endl;
  return 0;
}