#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-10;

template<typename T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<typename T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<typename T> inline bool semige(T x, T y){ return y - x < -EPS; }
template<typename T> inline bool semile(T x, T y){ return x - y < -EPS; }


struct Point : public complex<double>
{
public:
  Point(const double x = 0.0, const double y = 0.0) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // ??????
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // ??????
};

namespace std
{
  inline bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
typedef vector<Point> Polygon;
inline Point currPoint(vector<Point> P, int i){ return P[i]; }
inline Point nextPoint(vector<Point> P, int i){ return P[(i+1)%P.size()]; }
inline Point diffPoint(vector<Point> P, int i){ return nextPoint(P, i) - currPoint(P, i); }

int ccw(Point a, Point b, Point c)
{
  b -= a;
  c -= a;
  if(b.det(c) > 0.0)    return  1;         // counter clockwise
  if(b.det(c) < 0.0)    return -1;         // clockwise
  if(b.dot(c) < 0.0)    return  2;         // c--a--b on line
  if(norm(b) < norm(c)) return -2;         // a--b--c on line
  return 0;
}


struct Line : public vector<Point>
{
public:
  Line(){ }
  Line(Point P, Point Q){ this->pb(P);  this->pb(Q); }
  Line(double px, double py, double qx, double qy){ this->pb(Point(px, py));  this->pb(Point(qx, qy)); }
};
typedef Line Segment;

struct Circle : Point
{
private:
  Point p;
  double r;

public:
  Circle() : p(Point(0.0, 0.0)), r(0.0) {}
  Circle(Point p, double r) : p(p), r(r) {}
  Circle(double x, double y, double r) : p(Point(x, y)), r(r) {}
  inline Point center(){ return this->p; }
  inline double radius(){ return this->r; }
};

inline Point projectionOfLP(Line L, Point P){return L[0]+(Point(P-L[0])).dot(L[0]-L[1])/norm(L[0]-L[1])*(L[0]-L[1]);}
inline Point reflectionOfLP(Line L, Point P){return P+2.0*(projectionOfLP(L, P)-P);}
inline bool intersectionDeterminationOfLL(Line L, Line M){return abs(Point(L[1]-L[0]).det(M[1]-M[0]))>EPS||abs(Point(L[1]-L[0]).det(M[0]-L[0]))<EPS;}
inline bool intersectionDeterminationOfLS(Line L, Segment S){return(Point(L[1]-L[0]).det(S[0]-L[0]))
*(Point(L[1]-L[0]).det(S[1]-L[0]))<EPS;}
inline bool intersectionDeterminationOfLP(Line L, Point P){return abs(Point(L[1]-P).det(L[0]-P))<EPS;}
inline bool intersectionDeterminationOfSS(Segment S, Segment T){return ccw(S[0],S[1],T[0])*ccw(S[0],S[1],T[1])<=0&&ccw(T[0],T[1],S[0])*ccw(T[0],T[1],S[1])<=0;}
inline bool intersectionDeterminationOfSP(Segment S, Point P){return abs(S[0]-P)+abs(S[1]-P)-abs(S[1]-S[0])<EPS;}
inline double distanceOfLP(Line L, Point P){return abs(P-projectionOfLP(L,P));}
inline double distanceOfLL(Line L, Line M){return intersectionDeterminationOfLL(L,M)?0.0:distanceOfLP(L,M[0]);}
inline double distanceOfLS(Line L, Segment S){return intersectionDeterminationOfLS(L,S)?0.0:min(distanceOfLP(L,S[0]),distanceOfLP(L,S[1]));}
inline double distanceOfSP(Segment S, Point P){Point r=projectionOfLP(S,P);return intersectionDeterminationOfSP(S,r)?abs(r-P):min(abs(S[0]-P),abs(S[1]-P));}
inline double distanceOfSS(Segment S, Segment T){return intersectionDeterminationOfSS(S,T)?0.0:min(min(distanceOfSP(S,T[0]),distanceOfSP(S,T[1])),min(distanceOfSP(T,S[0]),distanceOfSP(T,S[1])));}
Point intersectionOfLL(Line L, Line M)
{
  double A = Point(L[1]-L[0]).det(M[1]-M[0]);
  double B = Point(L[1]-L[0]).det(L[1]-M[0]);
  if(abs(A)<EPS && abs(B)<EPS) return M[0];    // same line
  if(abs(A)<EPS) assert(false);
  return M[0] + B / A * (M[1] - M[0]);
}
inline bool onLine(Point P, Line L){return semieq(Point(L[0]-P).det(L[1]-P),0.0);}
inline bool onSegment(Point P, Segment S){return semieq(Point(S[0]-P).det(S[1]-P),0.0)&&!semige(Point(S[0]-P).dot(S[1]-P),0.0);}


int N, M;
double sx, sy, ex, ey;
double ax, ay, bx, by;
double h[55];
vector<vector<Point> > P;
int main(int argc, char *argv[])
{
  while(cin >> N, N){
    cin >> sx >> sy >> ex >> ey;
    Segment S(sx, sy, ex, ey);
    P.clear();
    rep(i, N){
      cin >> ax >> ay >> bx >> by >> h[i];
      vector<Point> t;
      t.pb(Point(ax, ay));
      t.pb(Point(ax, by));
      t.pb(Point(bx, ay));
      t.pb(Point(bx, by));
      P.pb(t);
    }
    double res = INF;
    rep(i, N){
      bool ok = true;
      rep(j, 4){
        double d = distanceOfSS(S, Segment(P[i][j], P[i][(j + 1) % 4]));
        if(!semige(d, h[i])) minup(res, d);
        else minup(res, (h[i] * h[i] + d * d) / (2.0 * h[i]));
        ok &= !intersectionDeterminationOfSS(S, Segment(P[i][j], P[i][(j + 1) % 4]));
      }
      if(!ok){
        res = 0.0;
        break;
      }
    }
    printf("%.15f\n", res);
  }
  
  
  return 0;
}

Measured memory_bytes: 3364