#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const long long ooo = 9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N = 100105;
const double PI = acos(-1.0);
const double eps = 1e-6;
int o(int x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
long double x1, y1_, x2, y2, mx, my, vx, vy, d, L, ans = ooo;
int n, s = 0;
vector<pair<long double, int> > V;
int X[N], Y[N], R[N];
long double check(int k, long double t, int op) {
  double x = mx + vx * t, y = my + vy * t;
  return ((sqrt(d * d + t * t) + (long long)op * R[k]) *
          (sqrt(d * d + t * t) + (long long)op * R[k])) -
         ((X[k] - x) * (X[k] - x)) - ((Y[k] - y) * (Y[k] - y));
}
long double BI(int k, int op) {
  long double l = -1e12, r = 1e12, mid, c = check(k, l, op), cc;
  while (r - l > eps) {
    mid = (l + r) / 2, cc = check(k, mid, op);
    if (c > 0 && cc > 0 || c < 0 && cc < 0)
      l = mid;
    else
      r = mid;
  }
  return (l + r) / 2;
}
int main() {
  scanf("%Lf%Lf%Lf%Lf", &x1, &y1_, &x2, &y2);
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%d%d%d", &X[i], &Y[i], &R[i]);
  mx = (x1 + x2) / 2, my = (y1_ + y2) / 2,
  L = sqrt(((x1 - x2) * (x1 - x2)) + ((y1_ - y2) * (y1_ - y2))),
  vx = (y1_ - y2) / L, vy = (x2 - x1) / L, d = L / 2;
  for (int i = (1); i <= (n); ++i) {
    long double l = BI(i, 1), r = BI(i, -1);
    if (l > r) swap(l, r);
    V.push_back(make_pair(l - eps, -1)), V.push_back(make_pair(r + eps, 1));
  }
  V.push_back(make_pair(0, 0));
  sort((V).begin(), (V).end());
  for (int i = 0; i < V.size(); i++) {
    s += V[i].second;
    if (s == 0 || V[i].second == -1 && s == -1)
      ans = min(ans, sqrt(((V[i].first) * (V[i].first)) + ((d) * (d))));
  }
  cout << ans << endl;
  return 0;
}
