#include <bits/stdc++.h>
const long double PI = acos(-1.0);
const double eps = 1e-8;
int dcmp(double x) { return x > eps ? 1 : (x < -eps ? -1 : 0); }
struct Point {
  double x, y;
  Point() : x(0), y(0) {}
  Point(double x, double y) : x(x), y(y) {}
  void read() { scanf("%lf %lf", &x, &y); }
  void print() const { printf("%lf %lf\n", x, y); }
  friend Point operator+(const Point& a, const Point& b) {
    return Point(a.x + b.x, a.y + b.y);
  }
  friend Point operator-(const Point& a, const Point& b) {
    return Point(a.x - b.x, a.y - b.y);
  }
  friend bool operator==(const Point& a, const Point& b) {
    return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0;
  }
  friend Point operator*(const double a, const Point& b) {
    return Point(a * b.x, a * b.y);
  }
  friend Point operator*(const Point& b, const double a) {
    return Point(a * b.x, a * b.y);
  }
  friend double operator*(const Point& a, const Point& b) {
    return a.x * b.x + a.y * b.y;
  }
  friend double operator^(const Point& a, const Point& b) {
    return a.x * b.y - a.y * b.x;
  }
  friend Point operator/(const Point& b, const double a) {
    return Point(b.x / a, b.y / a);
  }
  double norm2() const { return x * x + y * y; }
  double norm() const { return sqrt(x * x + y * y); }
  double dist(const Point& b) const { return (*this - b).norm(); }
  Point rotate(double a) const { return rotate(sin(a), cos(a)); }
  Point rotate(double sina, double cosa) const {
    return Point(x * cosa - y * sina, x * sina + y * cosa);
  }
  double get_rotate_angle_to_x_axis() const {
    if (dcmp(x) == 0) {
      return y > 0 ? -PI / 2 : PI / 2;
    }
    if (dcmp(y) == 0) {
      return x > 0 ? 0 : PI;
    }
    return -atan2(y, x);
  }
};
struct Line {
  Point a, b;
  Line() : Line(0, 0, 0, 0) {}
  Line(Point x, Point y) : a(x), b(y) {}
  Line(double x1, double y1, double x2, double y2)
      : a(Point(x1, y1)), b(Point(x2, y2)) {}
  void read() { scanf("%lf %lf %lf %lf", &a.x, &a.y, &b.x, &b.y); }
  double point_distance(const Point& p) const {
    if (dcmp((p - a) * (b - a)) < 0) return (p - a).norm();
    if (dcmp((p - b) * (a - b)) < 0) return (p - b).norm();
    return fabs((a - p) ^ (b - p) / (a - b).norm());
  }
  Point point_projection(const Point& p) const {
    auto l = b - a;
    auto r = l * (p - a) / l.norm2();
    return a + r * (b - a);
  }
  bool has_point(const Point& p) const {
    return dcmp((p - a) ^ (b - a)) == 0 && dcmp((p - a) * (p - b)) <= 0;
  }
  bool parallel(const Line& l) const {
    return dcmp((a - b) ^ (l.a - l.b)) == 0;
  }
  Point intersect(const Line& l) const {
    auto s1 = (a - l.a) ^ (l.b - l.a);
    auto s2 = (b - l.a) ^ (l.b - l.a);
    return Point(s1 * l.b - s2 * l.a) / (s1 - s2);
  }
  Line bisector() const {
    Point m((a.x + b.x) / 2, (a.y + b.y) / 2);
    if (a.x == b.x) {
      return Line(a.x + 1, m.y, a.x, m.y);
    }
    if (a.y == b.y) {
      return Line(m.x, a.y + 1, m.x, a.y);
    }
    auto K = (a.x - b.x) / (b.y - a.y);
    auto B = m.y - K * m.x;
    return Line(m.x, m.y, m.x + 1, K * (m.x + 1) + B);
  }
  void getABC(double& A, double& B, double& C) const {
    if (dcmp(a.x - b.x) == 0) {
      A = -1;
      B = 0;
      C = a.x;
      return;
    }
    if (dcmp(a.y - b.y) == 0) {
      A = 0;
      B = -1;
      C = a.y;
      return;
    }
    A = (a.y - b.y) / (a.x - b.x);
    B = -1;
    C = a.y - a.x * A;
  }
  std::vector<Point> intersect_hyperbola(double ha, double hb) const {
    std::vector<Point> points;
    double A, B, C;
    getABC(A, B, C);
    auto delta = -A * A * ha * ha + B * B * hb * hb + C * C;
    auto flag = dcmp(delta);
    if (flag < 0) {
      return points;
    }
    delta = sqrt(delta);
    points.push_back(Point(-(C + B * (B * C * hb * hb + A * ha * hb * delta) /
                                     (A * A * ha * ha - B * B * hb * hb)) /
                               A,
                           (B * C * hb * hb + A * ha * hb * delta) /
                               (A * A * ha * ha - B * B * hb * hb)));
    if (flag == 1) {
      points.push_back(Point(-(C + B * (B * C * hb * hb - A * ha * hb * delta) /
                                       (A * A * ha * ha - B * B * hb * hb)) /
                                 A,
                             (B * C * hb * hb - A * ha * hb * delta) /
                                 (A * A * ha * ha - B * B * hb * hb)));
    }
    return points;
  }
};
struct Circle {
  Point c;
  double r;
  Circle() : Circle(0, 0, 0) {}
  Circle(Point c, double r) : c(c), r(r) {}
  Circle(double x, double y, double r) : c(Point(x, y)), r(r) {}
  Point pointAt(double a) const {
    return Point(c.x + cos(a) * r, c.y + sin(a) * r);
  }
  void read() { scanf("%lf %lf %lf", &c.x, &c.y, &r); }
};
struct Range {
  double lower;
  double upper;
};
int main() {
  Line drawn;
  drawn.read();
  int n;
  scanf("%d", &n);
  std::vector<Circle> circles;
  circles.resize(n);
  for (int i = 0; i < n; ++i) {
    circles[i].read();
  }
  std::vector<Range> ranges;
  ranges.resize(n);
  for (int i = 0; i < n; ++i) {
    auto circle = circles[i];
    circle.c.x -= drawn.a.x;
    circle.c.y -= drawn.a.y;
    auto line = Line(Point(0, 0), drawn.b - drawn.a);
    auto ang = circle.c.get_rotate_angle_to_x_axis();
    circle.c = circle.c.rotate(ang);
    line.b = line.b.rotate(ang);
    auto ha = circle.r / 2;
    auto hc = circle.c.norm() / 2;
    auto hb = sqrt(hc * hc - ha * ha);
    line.a.x -= hc;
    line.b.x -= hc;
    circle.c.x -= hc;
    auto lb = line.bisector();
    auto intersections = lb.intersect_hyperbola(ha, hb);
    double r, r1, r2;
    int flag;
    switch (intersections.size()) {
      case 1:
        r = (intersections[0] - line.a).norm();
        flag = dcmp((intersections[0] - line.a) ^ (line.b - line.a));
        if (flag < 0) {
          r = -r;
        }
        ranges[i].lower = r < 0 ? r : -1e20;
        ranges[i].upper = r < 0 ? 1e20 : r;
        break;
      case 2:
        r1 = (intersections[0] - line.a).norm();
        r2 = (intersections[1] - line.a).norm();
        flag = dcmp((intersections[0] - line.a) ^ (line.b - line.a));
        if (flag < 0) {
          r1 = -r1;
        }
        flag = dcmp((intersections[1] - line.a) ^ (line.b - line.a));
        if (flag < 0) {
          r2 = -r2;
        }
        ranges[i].lower = r1 < r2 ? r1 : r2;
        ranges[i].upper = r1 < r2 ? r2 : r1;
        break;
      default:
        ranges[i].lower = 0;
        ranges[i].upper = 0;
        break;
    }
  }
  std::sort(ranges.begin(), ranges.end(), [](const Range& a, const Range& b) {
    if (dcmp(a.lower - b.lower) == 0) return a.upper < b.upper;
    return a.lower < b.lower;
  });
  auto ans = (drawn.a - drawn.b).norm() / 2;
  for (int i = 0; i < n; ++i) {
    auto& r = ranges[i];
    if (r.lower > ans) {
      break;
    }
    ans = std::max(ans, r.upper);
  }
  std::sort(ranges.begin(), ranges.end(), [](const Range& a, const Range& b) {
    if (dcmp(a.upper - b.upper) == 0) return a.lower > b.lower;
    return a.upper > b.upper;
  });
  auto ans2 = -(drawn.a - drawn.b).norm() / 2;
  for (int i = 0; i < n; ++i) {
    auto& r = ranges[i];
    if (r.upper < ans2) {
      break;
    }
    ans2 = std::min(ans2, r.lower);
  }
  ans = std::min(std::fabs(ans), std::fabs(ans2));
  printf("%lf\n", ans);
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

Masha's little brother draw two points on a sheet of paper. After that, he draws some circles and gave the sheet to his sister. 

Masha has just returned from geometry lesson so she instantly noticed some interesting facts about brother's drawing.

At first, the line going through two points, that brother drew, doesn't intersect or touch any circle.

Also, no two circles intersect or touch, and there is no pair of circles such that one circle is located inside another.

Moreover, for each circle, Masha drew a square of the minimal area with sides parallel axis such that this circle is located inside the square and noticed that there is no two squares intersect or touch and there is no pair of squares such that one square is located inside other.

Now Masha wants to draw circle of minimal possible radius such that it goes through two points that brother drew and doesn't intersect any other circle, but other circles can touch Masha's circle and can be located inside it.

It's guaranteed, that answer won't exceed 1012. It should be held for hacks as well.

Input

First line contains four integers x1, y1, x2, y2 ( - 105 ≤ x1, y1, x2, y2 ≤ 105) — coordinates of points that brother drew. First point has coordinates (x1, y1) and second point has coordinates (x2, y2). These two points are different.

The second line contains single integer n (1 ≤ n ≤ 105) — the number of circles that brother drew.

Next n lines contains descriptions of circles. Each line contains three integers xi, yi, ri ( - 105 ≤ xi, yi ≤ 105, 1 ≤ ri ≤ 105) describing circle with center (xi, yi) and radius ri.

Output

Output smallest real number, that it's possible to draw a circle with such radius through given points in such a way that it doesn't intersect other circles.

The output is considered correct if it has a relative or absolute error of at most 10 - 4.

Examples

Input

2 4 7 13
3
3 0 1
12 4 2
-4 14 2


Output

5.1478150705

Input

-2 3 10 -10
2
7 0 3
-5 -5 2


Output

9.1481831923

Note

<image> <image>

### Response

```cpp
#include <bits/stdc++.h>
const long double PI = acos(-1.0);
const double eps = 1e-8;
int dcmp(double x) { return x > eps ? 1 : (x < -eps ? -1 : 0); }
struct Point {
  double x, y;
  Point() : x(0), y(0) {}
  Point(double x, double y) : x(x), y(y) {}
  void read() { scanf("%lf %lf", &x, &y); }
  void print() const { printf("%lf %lf\n", x, y); }
  friend Point operator+(const Point& a, const Point& b) {
    return Point(a.x + b.x, a.y + b.y);
  }
  friend Point operator-(const Point& a, const Point& b) {
    return Point(a.x - b.x, a.y - b.y);
  }
  friend bool operator==(const Point& a, const Point& b) {
    return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0;
  }
  friend Point operator*(const double a, const Point& b) {
    return Point(a * b.x, a * b.y);
  }
  friend Point operator*(const Point& b, const double a) {
    return Point(a * b.x, a * b.y);
  }
  friend double operator*(const Point& a, const Point& b) {
    return a.x * b.x + a.y * b.y;
  }
  friend double operator^(const Point& a, const Point& b) {
    return a.x * b.y - a.y * b.x;
  }
  friend Point operator/(const Point& b, const double a) {
    return Point(b.x / a, b.y / a);
  }
  double norm2() const { return x * x + y * y; }
  double norm() const { return sqrt(x * x + y * y); }
  double dist(const Point& b) const { return (*this - b).norm(); }
  Point rotate(double a) const { return rotate(sin(a), cos(a)); }
  Point rotate(double sina, double cosa) const {
    return Point(x * cosa - y * sina, x * sina + y * cosa);
  }
  double get_rotate_angle_to_x_axis() const {
    if (dcmp(x) == 0) {
      return y > 0 ? -PI / 2 : PI / 2;
    }
    if (dcmp(y) == 0) {
      return x > 0 ? 0 : PI;
    }
    return -atan2(y, x);
  }
};
struct Line {
  Point a, b;
  Line() : Line(0, 0, 0, 0) {}
  Line(Point x, Point y) : a(x), b(y) {}
  Line(double x1, double y1, double x2, double y2)
      : a(Point(x1, y1)), b(Point(x2, y2)) {}
  void read() { scanf("%lf %lf %lf %lf", &a.x, &a.y, &b.x, &b.y); }
  double point_distance(const Point& p) const {
    if (dcmp((p - a) * (b - a)) < 0) return (p - a).norm();
    if (dcmp((p - b) * (a - b)) < 0) return (p - b).norm();
    return fabs((a - p) ^ (b - p) / (a - b).norm());
  }
  Point point_projection(const Point& p) const {
    auto l = b - a;
    auto r = l * (p - a) / l.norm2();
    return a + r * (b - a);
  }
  bool has_point(const Point& p) const {
    return dcmp((p - a) ^ (b - a)) == 0 && dcmp((p - a) * (p - b)) <= 0;
  }
  bool parallel(const Line& l) const {
    return dcmp((a - b) ^ (l.a - l.b)) == 0;
  }
  Point intersect(const Line& l) const {
    auto s1 = (a - l.a) ^ (l.b - l.a);
    auto s2 = (b - l.a) ^ (l.b - l.a);
    return Point(s1 * l.b - s2 * l.a) / (s1 - s2);
  }
  Line bisector() const {
    Point m((a.x + b.x) / 2, (a.y + b.y) / 2);
    if (a.x == b.x) {
      return Line(a.x + 1, m.y, a.x, m.y);
    }
    if (a.y == b.y) {
      return Line(m.x, a.y + 1, m.x, a.y);
    }
    auto K = (a.x - b.x) / (b.y - a.y);
    auto B = m.y - K * m.x;
    return Line(m.x, m.y, m.x + 1, K * (m.x + 1) + B);
  }
  void getABC(double& A, double& B, double& C) const {
    if (dcmp(a.x - b.x) == 0) {
      A = -1;
      B = 0;
      C = a.x;
      return;
    }
    if (dcmp(a.y - b.y) == 0) {
      A = 0;
      B = -1;
      C = a.y;
      return;
    }
    A = (a.y - b.y) / (a.x - b.x);
    B = -1;
    C = a.y - a.x * A;
  }
  std::vector<Point> intersect_hyperbola(double ha, double hb) const {
    std::vector<Point> points;
    double A, B, C;
    getABC(A, B, C);
    auto delta = -A * A * ha * ha + B * B * hb * hb + C * C;
    auto flag = dcmp(delta);
    if (flag < 0) {
      return points;
    }
    delta = sqrt(delta);
    points.push_back(Point(-(C + B * (B * C * hb * hb + A * ha * hb * delta) /
                                     (A * A * ha * ha - B * B * hb * hb)) /
                               A,
                           (B * C * hb * hb + A * ha * hb * delta) /
                               (A * A * ha * ha - B * B * hb * hb)));
    if (flag == 1) {
      points.push_back(Point(-(C + B * (B * C * hb * hb - A * ha * hb * delta) /
                                       (A * A * ha * ha - B * B * hb * hb)) /
                                 A,
                             (B * C * hb * hb - A * ha * hb * delta) /
                                 (A * A * ha * ha - B * B * hb * hb)));
    }
    return points;
  }
};
struct Circle {
  Point c;
  double r;
  Circle() : Circle(0, 0, 0) {}
  Circle(Point c, double r) : c(c), r(r) {}
  Circle(double x, double y, double r) : c(Point(x, y)), r(r) {}
  Point pointAt(double a) const {
    return Point(c.x + cos(a) * r, c.y + sin(a) * r);
  }
  void read() { scanf("%lf %lf %lf", &c.x, &c.y, &r); }
};
struct Range {
  double lower;
  double upper;
};
int main() {
  Line drawn;
  drawn.read();
  int n;
  scanf("%d", &n);
  std::vector<Circle> circles;
  circles.resize(n);
  for (int i = 0; i < n; ++i) {
    circles[i].read();
  }
  std::vector<Range> ranges;
  ranges.resize(n);
  for (int i = 0; i < n; ++i) {
    auto circle = circles[i];
    circle.c.x -= drawn.a.x;
    circle.c.y -= drawn.a.y;
    auto line = Line(Point(0, 0), drawn.b - drawn.a);
    auto ang = circle.c.get_rotate_angle_to_x_axis();
    circle.c = circle.c.rotate(ang);
    line.b = line.b.rotate(ang);
    auto ha = circle.r / 2;
    auto hc = circle.c.norm() / 2;
    auto hb = sqrt(hc * hc - ha * ha);
    line.a.x -= hc;
    line.b.x -= hc;
    circle.c.x -= hc;
    auto lb = line.bisector();
    auto intersections = lb.intersect_hyperbola(ha, hb);
    double r, r1, r2;
    int flag;
    switch (intersections.size()) {
      case 1:
        r = (intersections[0] - line.a).norm();
        flag = dcmp((intersections[0] - line.a) ^ (line.b - line.a));
        if (flag < 0) {
          r = -r;
        }
        ranges[i].lower = r < 0 ? r : -1e20;
        ranges[i].upper = r < 0 ? 1e20 : r;
        break;
      case 2:
        r1 = (intersections[0] - line.a).norm();
        r2 = (intersections[1] - line.a).norm();
        flag = dcmp((intersections[0] - line.a) ^ (line.b - line.a));
        if (flag < 0) {
          r1 = -r1;
        }
        flag = dcmp((intersections[1] - line.a) ^ (line.b - line.a));
        if (flag < 0) {
          r2 = -r2;
        }
        ranges[i].lower = r1 < r2 ? r1 : r2;
        ranges[i].upper = r1 < r2 ? r2 : r1;
        break;
      default:
        ranges[i].lower = 0;
        ranges[i].upper = 0;
        break;
    }
  }
  std::sort(ranges.begin(), ranges.end(), [](const Range& a, const Range& b) {
    if (dcmp(a.lower - b.lower) == 0) return a.upper < b.upper;
    return a.lower < b.lower;
  });
  auto ans = (drawn.a - drawn.b).norm() / 2;
  for (int i = 0; i < n; ++i) {
    auto& r = ranges[i];
    if (r.lower > ans) {
      break;
    }
    ans = std::max(ans, r.upper);
  }
  std::sort(ranges.begin(), ranges.end(), [](const Range& a, const Range& b) {
    if (dcmp(a.upper - b.upper) == 0) return a.lower > b.lower;
    return a.upper > b.upper;
  });
  auto ans2 = -(drawn.a - drawn.b).norm() / 2;
  for (int i = 0; i < n; ++i) {
    auto& r = ranges[i];
    if (r.upper < ans2) {
      break;
    }
    ans2 = std::min(ans2, r.lower);
  }
  ans = std::min(std::fabs(ans), std::fabs(ans2));
  printf("%lf\n", ans);
  return 0;
}

```