#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
struct PT {
  long double x, y;
  PT() : x(0), y(0) {}
  PT(long double x, long double y) : x(x), y(y) {}
  PT(const PT& p) : x(p.x), y(p.y) {}
  int operator<(const PT& rhs) const {
    return make_pair(y, x) < make_pair(rhs.y, rhs.x);
  }
  int operator==(const PT& rhs) const {
    return make_pair(y, x) == make_pair(rhs.y, rhs.x);
  }
  PT operator+(const PT& p) const { return PT(x + p.x, y + p.y); }
  PT operator-(const PT& p) const { return PT(x - p.x, y - p.y); }
  PT operator*(long double c) const { return PT(x * c, y * c); }
  PT operator/(long double c) const { return PT(x / c, y / c); }
};
long double cross(PT p, PT q) { return p.x * q.y - p.y * q.x; }
long double area(PT a, PT b, PT c) {
  return fabs(cross(a, b) + cross(b, c) + cross(c, a)) / 2;
}
long double area2(PT a, PT b, PT c) {
  return cross(a, b) + cross(b, c) + cross(c, a);
}
long double dot(PT p, PT q) { return p.x * q.x + p.y * q.y; }
long double dist(PT p, PT q) { return sqrt(dot(p - q, p - q)); }
long double dist2(PT p, PT q) { return dot(p - q, p - q); }
PT RotateCCW90(PT p) { return PT(-p.y, p.x); }
PT RotateCW90(PT p) { return PT(p.y, -p.x); }
PT RotateCCW(PT p, long double t) {
  return PT(p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t));
}
ostream& operator<<(ostream& os, const PT& p) {
  os << "(" << p.x << "," << p.y << ")";
  return os;
}
pair<long double, long double> solve(long double a, long double b,
                                     long double c) {
  long double delta = b * b - 4 * a * c;
  if (delta < 0) delta = 0;
  long double x1 = (-b - sqrt(delta)) / 2 / a;
  long double x2 = (-b + sqrt(delta)) / 2 / a;
  return make_pair(x1, x2);
}
inline long double sqr(long double x) { return x * x; }
const int maxn = 1e5 + 5;
int n;
PT a, b;
PT cen[maxn];
long double rad[maxn];
long double ff(int u) {
  long double lo = -1e12, hi = 1e12;
  int sign = 1;
  if (cen[u].x > 0) cen[u].x *= -1, sign = -1;
  for (int it = (0); it < (100); it++) {
    long double mi = (lo + hi) / 2;
    PT p = PT(mi, 0);
    int sign = 1;
    if (dist(p, cen[u]) <= dist(p, b) + rad[u]) {
      lo = mi;
    } else {
      hi = mi;
    }
  }
  cen[u].x *= sign;
  return sign * (lo + hi) / 2;
}
long double gg(int u) {
  long double lo = -1e12, hi = 1e12;
  int sign = 1;
  if (cen[u].x > 0) cen[u].x *= -1, sign = -1;
  for (int it = (0); it < (100); it++) {
    long double mi = (lo + hi) / 2;
    PT p = PT(mi, 0);
    int sign = 1;
    if (dist(p, cen[u]) <= dist(p, b) - rad[u]) {
      lo = mi;
    } else {
      hi = mi;
    }
  }
  cen[u].x *= sign;
  return sign * (lo + hi) / 2;
}
void solve() {
  cin >> a.x >> a.y >> b.x >> b.y;
  b = b - a;
  cin >> n;
  for (int i = (0); i < (n); i++)
    cin >> cen[i].x >> cen[i].y >> rad[i], cen[i] = cen[i] - a;
  long double al = atan2(b.y, b.x);
  b = RotateCCW(b, PI / 2 - al);
  for (int i = (0); i < (n); i++) {
    cen[i] = RotateCCW(cen[i], PI / 2 - al);
    cen[i].y -= b.y / 2;
  }
  b.y /= 2;
  vector<pair<long double, int> > events;
  events.push_back(make_pair(0, 2));
  for (int i = (0); i < (n); i++) {
    double l = gg(i);
    double r = ff(i);
    if (l > r) swap(l, r);
    events.push_back(make_pair(l, 0));
    events.push_back(make_pair(r, 1));
  }
  sort((events).begin(), (events).end());
  int ptr = 0, cnt = 0;
  long double ans = 1e100;
  for (int i = (0); i < (int((events).size())); i++) {
    int add = 0;
    while (ptr < int((events).size()) &&
           !sign(events[ptr].first, events[i].first)) {
      if (!events[ptr].second) {
        add++;
      } else if (events[ptr].second == 1) {
        cnt--;
      }
      ptr++;
    }
    if (!cnt) {
      chkmin(ans, dist(PT(events[i].first, 0), b));
    }
    cnt += add;
  }
  cout << fixed << setprecision(9) << ans << "\n";
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int JUDGE_ONLINE = 1;
  if (argc > 1) {
    JUDGE_ONLINE = 0;
    assert(freopen(argv[1], "r", stdin));
  }
  if (argc > 2) {
    JUDGE_ONLINE = 0;
    assert(freopen(argv[2], "wb", stdout));
  }
  solve();
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
