Problem: 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>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-10;
struct circle {
  pair<long double, long double> p;
  long double r;
};
inline int sign(double x) { return x < -eps ? -1 : x > eps; }
pair<long double, long double> operator*(
    const pair<long double, long double> &l,
    const pair<long double, long double> &r) {
  return {l.first * r.first - l.second * r.second,
          l.first * r.second + l.second * r.first};
}
pair<long double, long double> operator-(
    const pair<long double, long double> &l,
    const pair<long double, long double> &r) {
  return {l.first - r.first, l.second - r.second};
}
inline long double dot(pair<long double, long double> &a,
                       pair<long double, long double> &b) {
  return (pair<long double, long double>(a.second, a.first) * b).first;
}
inline long double cross(pair<long double, long double> &a,
                         pair<long double, long double> &b) {
  return (pair<long double, long double>(a.second, a.first) * b).second;
}
inline int ccw(pair<long double, long double> a,
               pair<long double, long double> b,
               pair<long double, long double> c) {
  b = b - a;
  c = c - a;
  if (cross(b, c) > 0) return +1;
  if (cross(b, c) < 0) return -1;
  if (dot(b, c) < 0) return +2;
  if (dot(b, b) < dot(c, c)) return -2;
  return 0;
}
inline long double dist(pair<long double, long double> a,
                        pair<long double, long double> b) {
  long double d1 = a.first - b.first, d2 = a.second - b.second;
  return sqrt(d1 * d1 + d2 * d2);
}
inline pair<long double, long double> three_point_circle(
    pair<long double, long double> A, pair<long double, long double> B,
    pair<long double, long double> C) {
  long double yDelta_a = B.second - A.second;
  long double xDelta_a = B.first - A.first;
  long double yDelta_b = C.second - B.second;
  long double xDelta_b = C.first - B.first;
  pair<long double, long double> center = pair<long double, long double>(0, 0);
  long double aSlope = yDelta_a / xDelta_a;
  long double bSlope = yDelta_b / xDelta_b;
  center.first = (aSlope * bSlope * (A.second - C.second) +
                  bSlope * (A.first + B.first) - aSlope * (B.first + C.first)) /
                 (2 * (bSlope - aSlope));
  center.second = -1 * (center.first - (A.first + B.first) / 2) / aSlope +
                  (A.second + B.second) / 2;
  return center;
}
inline int intersect(circle C, circle D) {
  long double d = dist(C.p, D.p);
  if (sign(d - C.r - D.r) > 0) return 0;
  if (sign(d - abs(C.r - D.r)) < 0) return 1;
  long double a = (C.r * C.r - D.r * D.r + d * d) / (2 * d);
  long double h = sqrt(C.r * C.r - a * a);
  if (sign(h) == 0) return 2;
  return 3;
}
inline pair<long double, long double> rotacion(pair<long double, long double> x,
                                               long double ang) {
  return {x.first * cos(ang) - x.second * sin(ang),
          x.first * sin(ang) + x.second * cos(ang)};
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  pair<long double, long double> a, b;
  long double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  a = {x1, y1}, b = {x2, y2};
  int n;
  cin >> n;
  vector<circle> v(n);
  for (auto &i : v) {
    long double x, y, r;
    cin >> x >> y >> r;
    i = {{x, y}, r};
  }
  if (x1 > x2) swap(a, b);
  long double ang = asin((a.second - b.second) / dist(a, b));
  for (auto &c : v) c.p = rotacion(c.p, ang);
  a = rotacion(a, ang);
  b = rotacion(b, ang);
  long double r = dist(a, b) / 2.0;
  long double x = (a.first + b.first) / 2.0;
  vector<vector<pair<long double, long double>>> s(2);
  for (auto &c : v) {
    bool op = c.p.second > a.second;
    long double fb = a.second - r, e = a.second, sb;
    while (e - fb > eps) {
      long double m = (fb + e) / 2.0;
      pair<long double, long double> center =
          three_point_circle(a, pair<long double, long double>(x, m), b);
      int d = intersect(c, {center, dist(center, a)});
      if (op) {
        if (d == 0)
          fb = m;
        else
          e = m;
      } else {
        if (d == 0)
          e = m;
        else
          fb = m;
      }
    }
    sb = a.second - r, e = a.second;
    while (e - sb > eps) {
      long double m = (sb + e) / 2.0;
      pair<long double, long double> center =
          three_point_circle(a, pair<long double, long double>(x, m), b);
      int d = intersect(c, {center, dist(center, a)});
      if (op) {
        if (d != 1)
          sb = m;
        else
          e = m;
      } else {
        if (d != 1)
          e = m;
        else
          sb = m;
      }
    }
    if (abs(fb - sb) > eps) {
      s[0].push_back(
          {dist(three_point_circle(a, pair<long double, long double>(x, fb), b),
                a),
           dist(three_point_circle(a, pair<long double, long double>(x, sb), b),
                a)});
      if (s[0].back().second < s[0].back().first)
        swap(s[0].back().first, s[0].back().second);
    }
  }
  for (auto &c : v) {
    bool op = c.p.second < a.second;
    long double fb = a.second, e = a.second + r, sb;
    while (e - fb > eps) {
      long double m = (fb + e) / 2.0;
      pair<long double, long double> center =
          three_point_circle(a, pair<long double, long double>(x, m), b);
      int d = intersect(c, {center, dist(center, a)});
      if (op) {
        if (d == 0)
          e = m;
        else
          fb = m;
      } else {
        if (d == 0)
          fb = m;
        else
          e = m;
      }
    }
    sb = a.second, e = a.second + r;
    while (e - sb > eps) {
      long double m = (sb + e) / 2.0;
      pair<long double, long double> center =
          three_point_circle(a, pair<long double, long double>(x, m), b);
      int d = intersect(c, {center, dist(center, a)});
      if (op) {
        if (d != 1)
          e = m;
        else
          sb = m;
      } else {
        if (d != 1)
          sb = m;
        else
          e = m;
      }
    }
    if (abs(fb - sb) > eps) {
      s[1].push_back(
          {dist(three_point_circle(a, pair<long double, long double>(x, fb), b),
                a),
           dist(three_point_circle(a, pair<long double, long double>(x, sb), b),
                a)});
      if (s[1].back().second < s[1].back().first)
        swap(s[1].back().first, s[1].back().second);
    }
  }
  long double ans = 1e13;
  for (int i = 0; i < 2; ++i) {
    s[i].push_back({r, r});
    s[i].push_back({1e13, 1e13});
    sort(s[i].begin(), s[i].end());
    long double last = dist(a, b) / 2.0;
    for (auto x : s[i]) {
      if (x.first - eps > last) {
        ans = min(ans, last);
        break;
      }
      last = max(last, x.second);
    }
  }
  cout << setprecision(10) << fixed << ans << "\n";
  return 0;
}