#include <cstdio>
#include <algorithm>
#include <complex>
#include <cmath>
#include <utility>
using namespace std;

#define EPS 1e-8

typedef complex<double> P;
typedef const P &rP;
typedef pair<P,P> seg;

double dot(rP a, rP b){
	return real(a) * real(b) + imag(a) * imag(b);
}

double cross(rP a, rP b){
	return real(a) * imag(b) - imag(a) * real(b);
}

int ccw(const seg &s, P c){
	P b = s.second - s.first;
	c -= s.first;
	double cr = cross(b, c);
	if(cr < -EPS){ return 1; }
	if(cr > EPS){ return -1; }
	if(dot(b, c) < -EPS){ return 2; }
	if(norm(b) < norm(c) - EPS){ return -2; }
	return 0;
}

bool intersectSS(const seg &s, const seg &t){
	return ccw(s, t.first) * ccw(s, t.second) <= 0 &&
	       ccw(t, s.first) * ccw(t, s.second) <= 0;
}

double distanceSP(const seg &s, rP c){
	rP a = s.first, b = s.second;
	if(dot(b - a, c - a) <= 0.0) return abs(c - a);
	if(dot(a - b, c - b) <= 0.0) return abs(c - b);
	return abs(cross(b - a, c - a)) / abs(b - a);
}

double distanceSS(const seg &s, const seg &t){
	if(intersectSS(s, t)){ return 0.0; }
	return min(min(distanceSP(s, t.first), distanceSP(s, t.second)),
	           min(distanceSP(t, s.first), distanceSP(t, s.second)));
}

int main(){
	int n;
	double x1, x2, y1, y2, h;
	while(scanf("%d%lf%lf%lf%lf", &n, &x1, &y1, &x2, &y2) == 5){
		seg crs(P(x1, y1), P(x2, y2));
		double ans = 1e99;

		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &h);
			
			if(x1 <= real(crs.first) && real(crs.first) <= x2 &&
			   y1 <= imag(crs.first) && imag(crs.first) <= y2){
				ans = 0.0;
			}
			
			P box[5];
			box[0] = box[4] = P(x1, y1);
			box[1] = P(x1, y2);
			box[2] = P(x2, y2);
			box[3] = P(x2, y1);

			for(int j = 0; j < 4; ++j){
				double d = distanceSS(crs, seg(box[j], box[j + 1]));
				double r;
				if(d <= h){
					r = d;
				}
				else{
					r = (d * d + h * h) / (2.0 * h);
				}
				ans = min(ans, r);
			}
		}
		printf("%.9f\n", ans);
	}
}