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 <typename point_type>
struct point {
  point_type x, y;
  point() { x = 0, y = 0; }
  point(point_type xx, point_type yy) { x = xx, y = yy; }
  template <typename point_type2>
  point(point<point_type2> from) {
    x = from.x, y = from.y;
  }
  point operator-(point second) { return point(x - second.x, y - second.y); }
  bool operator<(point second) {
    return make_pair(x, y) < make_pair(second.x, second.y);
  }
};
template <typename point_type>
double find_distance(point<point_type> p1, point<point_type> p2) {
  return hypot(p1.x - p2.x, p1.y - p2.y);
}
template <typename point_type>
struct segment {
  point<point_type> p1, p2;
  segment() { p1 = point<point_type>(), p2 = point<point_type>(); }
  segment(point<point_type> pp1, point<point_type> pp2) { p1 = pp1, p2 = pp2; }
  double length() { return find_distance(p1, p2); }
};
template <typename point_type>
struct line {
  point_type a, b, c;
  line() { a = 0, b = 0, c = 0; }
  line(point<point_type> pp1, point<point_type> pp2) {
    a = pp1.y - pp2.y;
    b = pp2.x - pp1.x;
    c = -(a * pp1.x + b * pp1.y);
  }
};
template <typename arg_type>
arg_type cross_product(point<arg_type> a, point<arg_type> b) {
  return a.x * b.y - b.x * a.y;
}
template <typename point_type>
istream &operator>>(istream &in, point<point_type> &input_point) {
  in >> input_point.x >> input_point.y;
  return in;
}
template <typename line_type>
point<double> line_intersection(line<line_type> line1, line<line_type> line2) {
  double divisor = line1.a * line2.b - line1.b * line2.a;
  return point<double>((line1.b * line2.c - line2.b * line1.c) / divisor,
                       (line2.a * line1.c - line1.a * line2.c) / divisor);
}
template <typename num_type>
int sign(num_type number) {
  return number == 0 ? 0 : abs(number) / number;
}
template <typename segment_type>
pair<int, point<double> > segment_intersection(segment<segment_type> segment1,
                                               segment<segment_type> segment2) {
  segment_type cross_product1 = cross_product(segment2.p1 - segment1.p1,
                                              segment1.p2 - segment1.p1),
               cross_product2 = cross_product(segment2.p2 - segment1.p1,
                                              segment1.p2 - segment1.p1),
               cross_product3 = cross_product(segment1.p1 - segment2.p1,
                                              segment2.p2 - segment2.p1),
               cross_product4 = cross_product(segment1.p2 - segment2.p1,
                                              segment2.p2 - segment2.p1),
               cross_product5 = cross_product(segment1.p2 - segment1.p1,
                                              segment2.p2 - segment2.p1);
  if (cross_product5 == 0 || cross_product1 == 0)
    return make_pair(-1, point<double>());
  if (sign(cross_product1) != sign(cross_product2) &&
      sign(cross_product3) != sign(cross_product4)) {
    line<segment_type> line1(segment1.p1, segment1.p2),
        line2(segment2.p1, segment2.p2);
    return make_pair(0, line_intersection(line1, line2));
  } else
    return make_pair(-1, point<double>());
}
int main() {
  cout << fixed << setprecision(6);
  point<int> point_strt, point_end, vertex[50];
  int vertex_number;
  cin >> point_strt >> point_end;
  cin >> vertex_number;
  for (int i = 0; i < vertex_number; i++) cin >> vertex[i];
  double perimeter = 0;
  segment<int> main_segment(point_strt, point_end);
  pair<int, point<double> > intersection1, intersection2;
  intersection1.first = intersection2.first = -1;
  for (int i = 0; i < vertex_number; i++) {
    segment<int> current_segment(vertex[i], vertex[(i + 1) % vertex_number]);
    perimeter += current_segment.length();
    if (intersection1.first == -1) {
      intersection1 = segment_intersection(main_segment, current_segment);
      if (intersection1.first == 0) intersection1.first = i;
    } else if (intersection2.first == -1) {
      intersection2 = segment_intersection(main_segment, current_segment);
      if (intersection2.first == 0) intersection2.first = i;
    }
  }
  double way = main_segment.length();
  if (intersection2.first > -1) {
    double through = find_distance(intersection1.second, intersection2.second);
    way -= through;
    double half1 =
        find_distance(
            intersection1.second,
            point<double>(vertex[(intersection1.first + 1) % vertex_number])) +
        find_distance(intersection2.second,
                      point<double>(vertex[intersection2.first]));
    for (int i = (intersection1.first + 1) % vertex_number;
         i != intersection2.first; i = (i + 1) % vertex_number)
      half1 += find_distance(vertex[i], vertex[(i + 1) % vertex_number]);
    double half2 = perimeter - half1;
    way += min(min(half1, half2), through * 2);
  }
  cout << way;
  return 0;
}