#include <bits/stdc++.h>

#define rep(i,n) for(int i=0; i<(n); i++)
#define all(X) X.begin(),X.end()
//#define X first
//#define Y second
#define eb emplace_back
#define pb push_back

using namespace std;
typedef pair<int,int> pii;
typedef vector<vector<pii>> Graph;

const double INF=1e10;
const double EPS=1e-8;
inline int sign(double x){ return abs(x) < EPS ? 0 : (x>0 ? 1 : -1 ); }

struct Point3D{
	double x, y, z;
	Point3D(): x(0), y(0), z(0) {}
	Point3D(double x, double y, double z): x(x), y(y), z(z) {}
	Point3D operator-() const { return Point3D(-x, -y, -z); }
	Point3D operator+(const Point3D &p) const {
		return Point3D(x+p.x, y+p.y, z+p.z);
	}
	Point3D operator-(const Point3D &p) const {
		return Point3D(x-p.x, y-p.y, z-p.z);
	}
	Point3D operator*(const double s) const {
		return Point3D( x*s, y*s, z*s );
	}
	Point3D operator/(const double s) const {
		return Point3D( x/s, y/s, z/s );
	}
};

struct Line3D {
	Point3D a, b;
	Line3D(): a(), b() {}
	Line3D(const Point3D &a, const Point3D &b): a(a), b(b) {}
};

inline double dot(const Point3D &a, const Point3D &b){
	return a.x * b.x + a.y * b.y + a.z * b.z;
}
inline Point3D cross(const Point3D &a, const Point3D &b){
	return Point3D(
		a.y * b.z - a.z * b.y,
		a.z * b.x - a.x * b.z,
		a.x * b.y - a.y * b.x
	);
}
inline double norm(const Point3D &p){ return dot(p, p); } 
inline double abs(const Point3D &p){ return sqrt(norm(p)); }
inline Point3D vec(const Line3D &l){ return l.b - l.a; }

inline Point3D projection(const Line3D &l, const Point3D &p){
	const Point3D v = vec(l);
	return l.a + v * (dot(p-l.a, v) / norm(v));
}

inline bool intersectSP(const Line3D &l, const Point3D &p){
	const Point3D a = p -l.a, b = vec(l);
	if(norm(a) < EPS || norm(a - b) < EPS){ return true; }
	if(norm(cross(a, b)) > EPS){ return false; }
	if(sign(a.x * b.x) < 0){ return false; }
	if(sign(a.y * b.y) < 0){ return false; }
	if(sign(a.z * b.z) < 0){ return false; }
	return norm(a) < norm(b);
}

inline double distanceLP(const Line3D &l, const Point3D &p){
	const Point3D q = projection(l,p);
	return abs(p - q);
}
inline double distanceSP(const Line3D &l, const Point3D &p){
	const Point3D u = p -l.a;
	const Point3D v = projection(Line3D(Point3D(), vec(l)), u);
	if(intersectSP(Line3D(Point3D(), vec(l)), v) ){ return abs(u-v); }
	return sqrt(min(norm(p - l.a), norm(p - l.b)));
}

namespace geom {
	#define X real()
	#define Y imag()
	#define at(i) ((*this)[i])
	enum {TRUE = 1, FALSE = 0, BORDER = -1};
	typedef long double R;
	typedef complex<R> P;
	const R INF = 1e8;
	inline int sig(const R &x) { return abs(x) < EPS ? 0 : x > 0 ? 1 : -1; }
	inline R norm(const P &p) {return p.X*p.X+p.Y*p.Y;}
	inline R inp(const P &a, const P &b) {return (conj(a)*b).X;}
	inline R outp(const P &a, const P &b) {return (conj(a)*b).Y;}
	inline int ccw(const P &s, const P &t, const P &p, int adv = 0) {
		int res = sig(outp(t-s, p-s));
		if(res || !adv) return res;
		if(sig(inp(t-s, p-s)) < 0) return -2;
		if(sig(inp(s-t, p-t)) < 0) return 2;
		return 0;
	}
	struct L : public vector<P>{
		L(const P &p1, const P &p2) {
			this->pb(p1); this->pb(p2);
		}
		L(){}
		P dir()const {return at(1) - at(0);}
		int online(const P &p) const {return !sig(outp(p-at(0), dir()));}
	};
	struct S : public L{
		S(const P &p1, const P &p2):L(p1, p2){}
		S(){}
		int online(const P &p) const {
			if(!sig(norm(p - at(0))) || !sig(norm(p - at(1)))) return BORDER;
			return !sig(outp(p-at(0), dir())) && inp(p-at(0), dir()) > EPS && inp(p-at(1), -dir()) > EPS;
		}
	};

	int intersect(const S &s, const S &t) {
		const int p = ccw(t[0], t[1], s[0], 1) * ccw(t[0], t[1], s[1], 1);
		const int q = ccw(s[0], s[1], t[0], 1) * ccw(s[0], s[1], t[1], 1);
		return (p>0 || q>0) ? FALSE : (!p || !q) ? BORDER : TRUE;
	}
};
using namespace geom;

Point3D pS, pG;
vector<Point3D> v;
vector<Line3D> e;

bool solve(double d){
	bool res = true;
	Line3D L( pS+Point3D(0.0, 0.0, d), pG+Point3D(0.,0., d) );
	for(auto t: v){
		t.z = min( t.z, d );
		if( distanceSP( L, t ) - d < EPS ){
			res = false;
		}
	}
	for(auto t: e){
		t.b.z = t.a.z = min( t.a.z, d );
		if( distanceSP( t, pS+Point3D(0.0, 0.0, d) ) - d < EPS ){
			res = false;
		}
		if( distanceSP( t, pG+Point3D(0.0, 0.0, d) ) - d < EPS ){
			res = false;
		}
	}
	return res;
}

int main() {
	int N;
	while(cin>>N, N){
		v.clear();
		e.clear();
			
		double x, y;
		cin >> x >> y;
		pS = Point3D(x, y, 0.0);
		cin >> x >> y;
		pG = Point3D(x, y, 0.0);

		bool zero = false;
		rep(i,N){
			double x1, y1, x2, y2, h;
			cin >> x1 >> y1 >> x2 >> y2 >> h;

			if( pS.x >= x1 && pS.y >= y1 && pS.x <= x2 && pS.y <= y2 &&
				pG.x >= x1 && pG.y >= y1 && pG.x <= x2 && pG.y <= y2 ){
				zero = true;
			}

			S s[4] = {
				S( P(x1,y1), P(x1,y2) ),
				S( P(x2,y1), P(x2,y2) ),
				S( P(x1,y1), P(x2,y1) ),
				S( P(x1,y2), P(x2,y2) )
			};
			rep(i,4){
				if( intersect( s[i], S(P(pS.x,pS.y), P(pG.x,pG.y)) ) ){
					zero = true;
				}
				e.eb( 	Point3D(s[i][0].X, s[i][0].Y, h),
						Point3D(s[i][1].X, s[i][1].Y, h) );
			}

			//v.eb( x1, y1, 0 );
			//v.eb( x1, y2, 0 );
			//v.eb( x2, y1, 0 );
			//v.eb( x2, y2, 0 );
			v.eb( x1, y1, h );
			v.eb( x1, y2, h );
			v.eb( x2, y1, h );
			v.eb( x2, y2, h );
		}

		if( zero ){
			cout << 0 << endl;
			continue;
		}

		double l=0.0, r=1000.0;
		rep(i,100){
			double m = (l+r) / 2.0;
			if( solve(m) ){
				l = m;
			}else{
				r = m;
			}
		}
		printf("%.10f\n", l);
	}
	return 0;
}