#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
struct pv {
  double x, y;
  pv(){};
  pv(double _x, double _y) {
    x = _x;
    y = _y;
  };
  pv operator+(const pv& B) { return pv(x + B.x, y + B.y); }
  pv operator-(const pv& B) { return pv(x - B.x, y - B.y); }
  pv operator/(const double& sc) { return pv(x / sc, y / sc); }
};
inline double LenSqr(pv a) { return a.x * a.x + a.y * a.y; }
inline double Len(pv a) { return sqrt(a.x * a.x + a.y * a.y); }
inline double Cp(pv a, pv b) { return a.x * b.y - a.y * b.x; }
inline int Sign(double x) {
  if (x < 0) return -1;
  return 1;
}
inline pv Norm(pv a, double sc) {
  double len = Len(a);
  return pv(a.x * sc / len, a.y * sc / len);
}
inline bool IsIn(pv a, double r1, pv b, double r2) {
  if (r1 - r2 > 0) {
    return 0;
  }
  return r2 - (Len(b - a) + r1) >= 0;
}
inline bool IsIns(pv a, double r1, pv b, double r2) {
  if (r1 - r2 < 0) {
    swap(r1, r2);
  }
  double lenS = LenSqr(b - a);
  if (lenS - r1 * r1 < 0) {
    if (lenS - (r1 - r2) * (r1 - r2) > 0) {
      return 1;
    }
  } else {
    if (lenS - (r1 + r2) * (r1 + r2) < 0) {
      return 1;
    }
  }
  return 0;
}
const int maxn = 1e5 + 10;
int n;
double r0;
pv a, b, c;
pair<pv, int> p[maxn];
vector<pair<double, int> > r;
double Solve(pv l) {
  bool ini = 0;
  double L, R, tL, tR, mid, r1;
  pv tc;
  r.clear();
  int i, j, cnt;
  for (i = (1); i <= (n); i++) {
    if (Sign(Cp(b - a, p[i].first - a)) == Sign(Cp(b - a, (c + l) - a))) {
      if (IsIn(p[i].first, p[i].second, c, r0)) {
        continue;
      }
      if (IsIns(p[i].first, p[i].second, c, r0)) {
        ini = 1;
        L = 0.0;
      } else {
        tL = 0.0;
        tR = 1.0 * 1e12;
        for (j = (1); j <= (100); j++) {
          mid = (tL + tR) / 2.0;
          tc = c + Norm(l, mid);
          r1 = sqrt(r0 * r0 + mid * mid);
          if (IsIn(p[i].first, p[i].second, tc, r1) ||
              IsIns(p[i].first, p[i].second, tc, r1)) {
            tR = mid;
          } else {
            tL = mid;
          }
        }
        L = tL;
      }
      tL = 0.0;
      tR = 1.0 * 1e12;
      for (j = (1); j <= (100); j++) {
        mid = (tL + tR) / 2.0;
        tc = c + Norm(l, mid);
        r1 = sqrt(r0 * r0 + mid * mid);
        if (IsIn(p[i].first, p[i].second, tc, r1)) {
          tR = mid;
        } else {
          tL = mid;
        }
      }
      R = tR;
    } else {
      if (!IsIn(p[i].first, p[i].second, c, r0) &&
          !IsIns(p[i].first, p[i].second, c, r0)) {
        continue;
      }
      if (IsIns(p[i].first, p[i].second, c, r0)) {
        ini = 1;
        L = 0.0;
      } else {
        tL = 0.0;
        tR = 1.0 * 1e12;
        for (j = (1); j <= (100); j++) {
          mid = (tL + tR) / 2.0;
          tc = c + Norm(l, mid);
          r1 = sqrt(r0 * r0 + mid * mid);
          if (IsIn(p[i].first, p[i].second, tc, r1)) {
            tL = mid;
          } else {
            tR = mid;
          }
        }
        L = tL;
      }
      tL = 0.0;
      tR = 1.0 * 1e12;
      for (j = (1); j <= (100); j++) {
        mid = (tL + tR) / 2.0;
        tc = c + Norm(l, mid);
        r1 = sqrt(r0 * r0 + mid * mid);
        if (IsIn(p[i].first, p[i].second, tc, r1) ||
            IsIns(p[i].first, p[i].second, tc, r1)) {
          tL = mid;
        } else {
          tR = mid;
        }
      }
      R = tR;
    }
    r.push_back(make_pair(L, -1));
    r.push_back(make_pair(R, 1));
  }
  sort(r.begin(), r.end());
  double dlt = 0.0;
  if (ini) {
    cnt = 0;
    for (auto k : r) {
      cnt += k.second;
      if (!cnt) {
        dlt = k.first;
        break;
      }
    }
  }
  return sqrt(dlt * dlt + r0 * r0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> a.x >> a.y >> b.x >> b.y;
  c = (a + b) / 2.0;
  r0 = Len(b - a) / 2.0;
  cin >> n;
  int i;
  for (i = (1); i <= (n); i++) {
    cin >> p[i].first.x >> p[i].first.y >> p[i].second;
  }
  cout.precision(10);
  cout << fixed
       << 1.0 * min(Solve(pv(-(b.y - a.y), b.x - a.x)),
                    Solve(pv(b.y - a.y, -(b.x - a.x))));
  return 0;
}
