#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef complex<ld> Point;

const ld eps = 1e-9, pi = acos(-1.0);

namespace std {
	bool operator<(const Point &lhs, const Point &rhs) {
		if (lhs.real() < rhs.real() - eps) return true;
		if (lhs.real() > rhs.real() + eps) return false;
		return lhs.imag() < rhs.imag();
	}
}

Point input_point() {
	ld x, y;
	cin >> x >> y;
	return Point(x, y);
}

bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}

// dot of a and b
ld dot(Point a, Point b) {
	return real(conj(a) * b);
}

// cross of a and b
ld cross(Point a, Point b) {
	return imag(conj(a) * b);
}

class Line {
public:
	Point a, b;
	Line() : a(Point(0, 0)), b(Point(0, 0)) {}
	Line(Point a, Point b) : a(a), b(b) {}
};

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

bool isis_ss(Line s, Line t) {
	return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
		ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

bool isis_sp(Line s, Point p) {
	return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}

Point proj(Line l, Point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}

ld dist_sp(Line s, Point p) {
	Point r = proj(s, p);
	return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}

ld dist_ss(Line s, Line t) {
	if (isis_ss(s, t)) return 0;
	return min({ dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b) });
}

struct Square{
    Point left_d,left_u,right_d,right_u;
    ld h;
    Square(Point left_d,Point left_u,Point right_d,Point right_u,ld h): 
        left_d(left_d),left_u(left_u),right_d(right_d),right_u(right_u),h(h){}
};

bool intersect(Square s, Point st, Point gt){
    bool ret=false;
    Line l=Line(st,gt);
    ret |= isis_ss(l, Line(s.left_d,s.left_u));
    ret |= isis_ss(l, Line(s.left_u,s.right_u));
    ret |= isis_ss(l, Line(s.right_u,s.right_d));
    ret |= isis_ss(l, Line(s.right_d,s.left_d));
    return ret;
}

bool check(const vector<Square> &v, Point st, Point gt, ld r){
    bool ret=true;
    int sz=v.size();
    Line l = Line(st,gt);
    for(int i=0;i<sz;i++){
        ld d=dist_ss(l,Line(v[i].left_d,v[i].left_u));
        d = min(d, dist_ss(l,Line(v[i].left_u,v[i].right_u)));
        d = min(d, dist_ss(l,Line(v[i].right_u,v[i].right_d)));
        d = min(d, dist_ss(l,Line(v[i].right_d,v[i].left_d)));

        if(v[i].h>r) ret &= (d+eps>r);
        else ret &= (d+eps > sqrt(r*r-(r-v[i].h)*(r-v[i].h)));
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(cin>>n,n){
        ld sx,sy,ex,ey;
        ld minx,miny,maxx,maxy,h;
        Point left_d,left_u,right_d,right_u;
        vector<Square> v;

        cin>>sx>>sy>>ex>>ey;
        Point st=Point(sx,sy),gt=Point(ex,ey);
        bool f=false;
        for(int i=0;i<n;i++){
            cin>>minx>>miny>>maxx>>maxy>>h;
            left_d=Point(minx,miny); left_u=Point(minx,maxy);
            right_d = Point(maxx,miny); right_u = Point(maxx,maxy);
            v.push_back(Square(left_d,left_u,right_d,right_u,h));
            f |= intersect(v[i],st,gt);

            if(minx<=sx&&sx<=maxx&&miny<=sy&&sy<=maxy&& minx<=ex&&ex<=maxx&&miny<=ey&&ey<=maxy) f=true;
        }
        if(f){
            cout<<fixed<<setprecision(10)<<0<<endl;
            continue;
        }
        ld low=0,high=1e6;
        for(int i=0;i<100;i++){
            ld mid=(low+high)/2;
            if(check(v,st,gt,mid)){
                low=mid;
            }
            else{
                high=mid;
            }
        }
        cout<<fixed<<setprecision(10)<<low<<endl;
    }
}


Measured memory_bytes: 3372