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

const double EPS = 1e-9;
typedef complex<double> P;

struct L : public vector<P>{ L(const P &a,const P &b){ push_back(a); push_back(b); } };

double cross(const P&a,const P &b){
	return imag(conj(a)*b);
}
double dot(const P&a,const P &b){
	return real(conj(a)*b);
}

int ccw(P a,P b,P c){
	b -= a; c-= a;
	if( cross(b,c) > 0 ) return +1;
	if( cross(b,c) < 0 ) return -1;
	if( dot(b,c) < 0 ) return +2;
	if( norm(b) < norm(c) ) return -2;
	return 0;
}
bool intersectSS(const L&s,const L&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;
}
P projection(const L &l,const P&p){
	double t = dot(p-l[0],l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t * (l[0]-l[1]);
}
bool intersectSP(const L&s,const P&p){ return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; }

double distanceSP(const L&s,const P&p){
	P r = projection(s,p);
	if( intersectSP(s,r) ) return abs(r-p);
	return min(abs(s[0]-p),abs(s[1]-p));
}
double distanceSS(const L &s,const L&t){
	if( intersectSS(s,t) ) return 0;
	return min(min(distanceSP(s,t[0]),distanceSP(s,t[1])),min(distanceSP(t,s[0]),distanceSP(t,s[1])));
}

P in(){
	double a,b;
	cin >> a >> b;
	return P(a,b);
}
int main(){
	int n;
	while( cin >> n && n ){
		P s = in();
		P g = in();
		bool allOk = 1;
		vector< pair<double,double> > lim;
		for(int i = 0 ; i < n ; i++){
			int x1,y1,x2,y2;
			double h;
			cin >> x1 >> y1 >> x2 >> y2 >> h;
			vector<P> p = {P(x1,y1),P(x2,y1),P(x2,y2),P(x1,y2)};
			double sub = 1e9;
			int flagS = 0;
			int flagG = 0;
			for(int j = 0 ; j < p.size() ; j++){
				P a = p[j];
				P b = p[(j+1)%p.size()];
				if( ccw(a,b,s) > 0 ) flagS++;
				if( ccw(a,b,g) > 0 ) flagG++;
				sub = min(distanceSS(L(a,b),L(s,g)),sub);
			}
			if(flagS == 4 || flagG == 4) allOk = 0;
			lim.push_back(make_pair(h,sub));
			//cout << h << " " << sub << endl;
		}
		double l = 0 , r = 1000000;
		for(int _ = 0 ; _ < 128 ; _++){
			double R = (l+r) / 2;
			bool flag = 1;
			for(int j = 0 ; j < lim.size() ; j++){
				double h = min(R,lim[j].first);
				double d = R*R-(R-h)*(R-h);
				d = sqrt(d);
				if( lim[j].second < d ) flag = 0;
				
			}
			if( allOk && flag ) l = R;
			else r = R;
		}
		printf("%.10lf\n",l);
	}
}