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;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T1, class T2>
inline void gn(T1 &x1, T2 &x2) {
  gn(x1), gn(x2);
}
template <class T1, class T2, class T3>
inline void gn(T1 &x1, T2 &x2, T3 &x3) {
  gn(x1), gn(x2), gn(x3);
}
template <class T1, class T2, class T3, class T4>
inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {
  gn(x1), gn(x2), gn(x3), gn(x4);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T1, class T2>
inline void print(T1 x1, T2 x2) {
  printsp(x1), println(x2);
}
template <class T1, class T2, class T3>
inline void print(T1 x1, T2 x2, T3 x3) {
  printsp(x1), printsp(x2), println(x3);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
struct point {
  double first, second;
  point(double first = 0, double second = 0) : first(first), second(second) {}
  point operator-(point a) { return point(first - a.first, second - a.second); }
  point operator+(point a) { return point(first + a.first, second + a.second); }
  point operator*(double a) { return point(first * a, second * a); }
  point operator/(double a) { return point(first / a, second / a); }
  point operator&(point a) {
    return point(first * a.first - second * a.second,
                 first * a.second + second * a.first);
  }
  point rotate(double al) { return *this & point(cos(al), sin(al)); }
  double operator^(point a) { return first * a.second - second * a.first; }
  double operator*(point a) { return first * a.first + second * a.second; }
  point norm() {
    double s = nor();
    if (s < 1e-9) return *this;
    return point(first / s, second / s);
  }
  point conj() { return point(-second, first); }
  double nor() { return sqrt(*this * *this); }
  double al() { return atan2(second, first); }
  bool operator<(const point &a) const {
    if (fabs(first - a.first) > 1e-9) return first < a.first;
    return second < a.second - 1e-9;
  }
  bool operator>(const point &a) const {
    if (fabs(first - a.first) > 1e-9) return first > a.first;
    return second > a.second + 1e-9;
  }
  bool operator==(const point &a) const {
    if (fabs(first - a.first) > 1e-9) return 0;
    return fabs(second - a.second) < 1e-9;
  }
  void input() { scanf("%lf %lf", &first, &second); }
  void print() { printf("%lf %lf\n", first, second); }
};
int sgn(double a) { return (a > 1e-9) - (a < -1e-9); }
int is_on(point a, point b, point c) {
  if (sgn(a - b ^ b - c)) return 0;
  return sgn((a - c) * (b - c)) <= 0;
}
double angle(point a, point b) {
  double res = a * b / a.nor() / b.nor();
  smin(res, 1.), smax(res, -1.);
  res = acos(res);
  return res;
}
double angle(point a, point b, point c) { return angle(a - c, b - c); }
double pdist(point c, point a, point b) {
  point aa = c - a, bb = c - b, ab = a - b;
  if (sgn(aa * ab) >= 0) return aa.nor();
  if (sgn(bb * ab) <= 0) return bb.nor();
  return fabs(aa ^ bb) / ab.nor();
}
bool is_in_poly(point a, point *p, int n) {
  for (int i = 0; i < n; i++)
    if (is_on(p[i], p[i + 1], a)) return 1;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    point b = p[i], c = p[i + 1];
    if (b > c) swap(b, c);
    if (sgn(c - b ^ a - b) < 0 && b.first < a.first - 1e-9 &&
        a.first < c.first + 1e-9)
      cnt++;
  }
  return cnt & 1;
}
struct circle {
  double first, second, r;
  circle(double first = 0, double second = 0, double r = 0)
      : first(first), second(second), r(r) {}
  void input() { scanf("%lf %lf %lf", &first, &second, &r); }
  void print() { printf("%.7lf %.7lf %.7lf\n", first, second, r); }
};
point circumcenter(point a, point b, point c) {
  point A = (b + c) / 2, B = (a + c) / 2;
  point da = (b - c).conj(), db = (a - c).conj();
  point aa = A + da, bb = B + db;
  double first = B - bb ^ A - bb, second = aa - bb ^ B - bb;
  return A + (aa - A) * (first / (first + second));
}
int n;
pair<double, double> p[200010];
point A, B, N, dir;
circle c;
void calc() {
  point C = point(c.first, c.second);
  if ((A - C ^ B - C) > 1e-9) {
    double st = -1e15, ed = 1e15;
    for (int i = 0; i < 70; i++) {
      double md = (st + ed) / 2;
      point D = N + dir * md;
      if ((A - D).nor() < (C - D).nor() - c.r)
        st = md;
      else
        ed = md;
    }
    p[n].first = st;
    st = -1e15, ed = 1e15;
    for (int i = 0; i < 70; i++) {
      double md = (st + ed) / 2;
      point D = N + dir * md;
      if ((A - D).nor() < (C - D).nor() + c.r)
        st = md;
      else
        ed = md;
    }
    p[n++].second = ed;
  } else {
    double st = -1e15, ed = 1e15;
    for (int i = 0; i < 70; i++) {
      double md = (st + ed) / 2;
      point D = N + dir * md;
      if ((A - D).nor() > (C - D).nor() + c.r)
        st = md;
      else
        ed = md;
    }
    p[n].first = st;
    st = -1e15, ed = 1e15;
    for (int i = 0; i < 70; i++) {
      double md = (st + ed) / 2;
      point D = N + dir * md;
      if ((A - D).nor() > (C - D).nor() - c.r)
        st = md;
      else
        ed = md;
    }
    p[n++].second = ed;
  }
}
bool cmp(pair<double, double> &a, pair<double, double> b) {
  if (a.second < b.first) return 0;
  smax(a.second, b.second);
  return 1;
}
int main() {
  A.input(), B.input();
  dir = (B - A).conj().norm();
  N = (A + B) / 2;
  int nn;
  gn(nn);
  while (nn--) c.input(), calc();
  int ok = 1;
  for (int i = 0; i < n; i++)
    if (p[i].first < -1e-9 and p[i].second > 1e-9) {
      ok = 0;
      break;
    }
  if (ok) return printf("%.7lf\n", (A - N).nor()), 0;
  sort(p, p + n);
  n = unique(p, p + n, cmp) - p;
  double ans = 1e15;
  for (int i = 0; i < n; i++) smin(ans, min(abs(p[i].first), abs(p[i].second)));
  printf("%.7lf\n", (A - (N + dir * ans)).nor());
  return 0;
}