#include <bits/stdc++.h>
using namespace std;
struct Pt {
  Pt(){};
  Pt(double xx, double yy) : x(xx), y(yy) {}
  double x, y;
};
struct Circle {
  Circle(){};
  Circle(double xx, double yy, double rr) : x(xx), y(yy), r(rr) {}
  double x, y, r;
};
double dist(Pt p1, Pt p2) {
  return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}
Pt intersect_2_lines(double a1, double b1, double c1, double a2, double b2,
                     double c2) {
  double x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
  double y = (a1 * c2 - a2 * c1) / (a2 * b1 - a1 * b2);
  Pt p(x, y);
  return p;
}
Circle circle_3_points(Pt p1, Pt p2, Pt p3) {
  Pt p12((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
  double a1 = p2.x - p1.x;
  double b1 = p2.y - p1.y;
  double c1 = -1 * (a1 * p12.x + b1 * p12.y);
  Pt p23((p2.x + p3.x) / 2, (p2.y + p3.y) / 2);
  double a2 = p3.x - p2.x;
  double b2 = p3.y - p2.y;
  double c2 = -1 * (a2 * p23.x + b2 * p23.y);
  Pt p = intersect_2_lines(a1, b1, c1, a2, b2, c2);
  Circle c(p.x, p.y, dist(p, p1));
  return c;
}
pair<double, double> binary_search_left(Pt p1, Pt p2, Circle c) {
  pair<double, double> ans;
  Pt p12((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
  double a1 = p2.x - p1.x;
  double b1 = p2.y - p1.y;
  double m1 = sqrt(a1 * a1 + b1 * b1);
  a1 /= m1;
  b1 /= m1;
  double la1 = -1 * b1;
  double lb1 = a1;
  double l = -1e13, r = 1e13;
  for (int i = 0; i < 100; i++) {
    double mid = (l + r) / 2;
    Pt pm(p12.x + mid * la1, p12.y + mid * lb1);
    double d1 = dist(pm, p2);
    double d2 = dist(pm, Pt(c.x, c.y)) + c.r;
    if (d1 > d2) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ans.first = l;
  l = -1e13, r = 1e13;
  for (int i = 0; i < 100; i++) {
    double mid = (l + r) / 2;
    Pt pm(p12.x + mid * la1, p12.y + mid * lb1);
    double d1 = dist(pm, p2);
    double d2 = dist(pm, Pt(c.x, c.y)) - c.r;
    if (d1 > d2) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ans.second = l;
  return ans;
}
pair<double, double> binary_search_right(Pt p1, Pt p2, Circle c) {
  pair<double, double> ans;
  Pt p12((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
  double a1 = p2.x - p1.x;
  double b1 = p2.y - p1.y;
  double m1 = sqrt(a1 * a1 + b1 * b1);
  a1 /= m1;
  b1 /= m1;
  double ra1 = b1;
  double rb1 = -1 * a1;
  double l = -1e13, r = 1e13;
  for (int i = 0; i < 100; i++) {
    double mid = (l + r) / 2;
    Pt pm(p12.x + mid * ra1, p12.y + mid * rb1);
    double d1 = dist(pm, p2);
    double d2 = dist(pm, Pt(c.x, c.y)) - c.r;
    if (d1 > d2) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ans.first = l;
  Pt pm(p12.x + l * ra1, p12.y + l * rb1);
  l = -1e13, r = 1e13;
  for (int i = 0; i < 100; i++) {
    double mid = (l + r) / 2;
    Pt pm(p12.x + mid * ra1, p12.y + mid * rb1);
    double d1 = dist(pm, p2);
    double d2 = dist(pm, Pt(c.x, c.y)) + c.r;
    if (d1 > d2) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ans.second = l;
  return ans;
}
double cp(Pt p1, Pt p2, Pt p3) {
  double xx1 = p2.x - p1.x;
  double yy1 = p2.y - p1.y;
  double xx2 = p3.x - p2.x;
  double yy2 = p3.y - p2.y;
  return xx1 * yy2 - xx2 * yy1;
}
double convert(double r, Pt p1, Pt p2) {
  return sqrt(r * r + (dist(p1, p2) / 2) * (dist(p1, p2) / 2));
}
double xx1, yy1, xx2, yy2;
long long n;
Circle c[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> xx1 >> yy1 >> xx2 >> yy2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i].x >> c[i].y >> c[i].r;
  }
  Pt p1(xx1, yy1), p2(xx2, yy2);
  vector<pair<double, double> > vp, vn;
  for (int i = 0; i < n; i++) {
    Pt p3(c[i].x, c[i].y);
    pair<double, double> p;
    if (cp(p1, p2, p3) > 0) {
      p = binary_search_left(p1, p2, c[i]);
      p = {-1 * p.first, -1 * p.second};
    } else {
      p = binary_search_right(p1, p2, c[i]);
    }
    if (p.first > 0)
      vp.push_back(p);
    else if (p.second < 0)
      vn.push_back(p);
    else {
      vp.push_back({0, p.second});
      vn.push_back({p.first, 0});
    }
  }
  for (int i = 0; i < vn.size(); i++) {
    vn[i] = {-1 * vn[i].second, -1 * vn[i].first};
  }
  double ans = 1e13;
  sort(vp.begin(), vp.end());
  sort(vn.begin(), vn.end());
  double cur = 0;
  for (int i = 0; i < vp.size(); i++) {
    if (cur + 1e-7 < vp[i].first) {
      break;
    }
    cur = max(cur, vp[i].second);
  }
  ans = min(ans, cur);
  cur = 0;
  for (int i = 0; i < vn.size(); i++) {
    if (cur + 1e-7 < vn[i].first) {
      break;
    }
    cur = max(cur, vn[i].second);
  }
  ans = min(ans, cur);
  cout << fixed;
  cout.precision(10);
  if (ans < 1e13) {
    cout << convert(ans, p1, p2) << endl;
  } else {
    cout << -1 << endl;
  }
}

### Prompt

Your challenge is to write a CPP solution to the following 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>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Pt {
  Pt(){};
  Pt(double xx, double yy) : x(xx), y(yy) {}
  double x, y;
};
struct Circle {
  Circle(){};
  Circle(double xx, double yy, double rr) : x(xx), y(yy), r(rr) {}
  double x, y, r;
};
double dist(Pt p1, Pt p2) {
  return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}
Pt intersect_2_lines(double a1, double b1, double c1, double a2, double b2,
                     double c2) {
  double x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
  double y = (a1 * c2 - a2 * c1) / (a2 * b1 - a1 * b2);
  Pt p(x, y);
  return p;
}
Circle circle_3_points(Pt p1, Pt p2, Pt p3) {
  Pt p12((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
  double a1 = p2.x - p1.x;
  double b1 = p2.y - p1.y;
  double c1 = -1 * (a1 * p12.x + b1 * p12.y);
  Pt p23((p2.x + p3.x) / 2, (p2.y + p3.y) / 2);
  double a2 = p3.x - p2.x;
  double b2 = p3.y - p2.y;
  double c2 = -1 * (a2 * p23.x + b2 * p23.y);
  Pt p = intersect_2_lines(a1, b1, c1, a2, b2, c2);
  Circle c(p.x, p.y, dist(p, p1));
  return c;
}
pair<double, double> binary_search_left(Pt p1, Pt p2, Circle c) {
  pair<double, double> ans;
  Pt p12((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
  double a1 = p2.x - p1.x;
  double b1 = p2.y - p1.y;
  double m1 = sqrt(a1 * a1 + b1 * b1);
  a1 /= m1;
  b1 /= m1;
  double la1 = -1 * b1;
  double lb1 = a1;
  double l = -1e13, r = 1e13;
  for (int i = 0; i < 100; i++) {
    double mid = (l + r) / 2;
    Pt pm(p12.x + mid * la1, p12.y + mid * lb1);
    double d1 = dist(pm, p2);
    double d2 = dist(pm, Pt(c.x, c.y)) + c.r;
    if (d1 > d2) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ans.first = l;
  l = -1e13, r = 1e13;
  for (int i = 0; i < 100; i++) {
    double mid = (l + r) / 2;
    Pt pm(p12.x + mid * la1, p12.y + mid * lb1);
    double d1 = dist(pm, p2);
    double d2 = dist(pm, Pt(c.x, c.y)) - c.r;
    if (d1 > d2) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ans.second = l;
  return ans;
}
pair<double, double> binary_search_right(Pt p1, Pt p2, Circle c) {
  pair<double, double> ans;
  Pt p12((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
  double a1 = p2.x - p1.x;
  double b1 = p2.y - p1.y;
  double m1 = sqrt(a1 * a1 + b1 * b1);
  a1 /= m1;
  b1 /= m1;
  double ra1 = b1;
  double rb1 = -1 * a1;
  double l = -1e13, r = 1e13;
  for (int i = 0; i < 100; i++) {
    double mid = (l + r) / 2;
    Pt pm(p12.x + mid * ra1, p12.y + mid * rb1);
    double d1 = dist(pm, p2);
    double d2 = dist(pm, Pt(c.x, c.y)) - c.r;
    if (d1 > d2) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ans.first = l;
  Pt pm(p12.x + l * ra1, p12.y + l * rb1);
  l = -1e13, r = 1e13;
  for (int i = 0; i < 100; i++) {
    double mid = (l + r) / 2;
    Pt pm(p12.x + mid * ra1, p12.y + mid * rb1);
    double d1 = dist(pm, p2);
    double d2 = dist(pm, Pt(c.x, c.y)) + c.r;
    if (d1 > d2) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ans.second = l;
  return ans;
}
double cp(Pt p1, Pt p2, Pt p3) {
  double xx1 = p2.x - p1.x;
  double yy1 = p2.y - p1.y;
  double xx2 = p3.x - p2.x;
  double yy2 = p3.y - p2.y;
  return xx1 * yy2 - xx2 * yy1;
}
double convert(double r, Pt p1, Pt p2) {
  return sqrt(r * r + (dist(p1, p2) / 2) * (dist(p1, p2) / 2));
}
double xx1, yy1, xx2, yy2;
long long n;
Circle c[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> xx1 >> yy1 >> xx2 >> yy2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i].x >> c[i].y >> c[i].r;
  }
  Pt p1(xx1, yy1), p2(xx2, yy2);
  vector<pair<double, double> > vp, vn;
  for (int i = 0; i < n; i++) {
    Pt p3(c[i].x, c[i].y);
    pair<double, double> p;
    if (cp(p1, p2, p3) > 0) {
      p = binary_search_left(p1, p2, c[i]);
      p = {-1 * p.first, -1 * p.second};
    } else {
      p = binary_search_right(p1, p2, c[i]);
    }
    if (p.first > 0)
      vp.push_back(p);
    else if (p.second < 0)
      vn.push_back(p);
    else {
      vp.push_back({0, p.second});
      vn.push_back({p.first, 0});
    }
  }
  for (int i = 0; i < vn.size(); i++) {
    vn[i] = {-1 * vn[i].second, -1 * vn[i].first};
  }
  double ans = 1e13;
  sort(vp.begin(), vp.end());
  sort(vn.begin(), vn.end());
  double cur = 0;
  for (int i = 0; i < vp.size(); i++) {
    if (cur + 1e-7 < vp[i].first) {
      break;
    }
    cur = max(cur, vp[i].second);
  }
  ans = min(ans, cur);
  cur = 0;
  for (int i = 0; i < vn.size(); i++) {
    if (cur + 1e-7 < vn[i].first) {
      break;
    }
    cur = max(cur, vn[i].second);
  }
  ans = min(ans, cur);
  cout << fixed;
  cout.precision(10);
  if (ans < 1e13) {
    cout << convert(ans, p1, p2) << endl;
  } else {
    cout << -1 << endl;
  }
}

```