#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <complex>
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
const double EPS = 1e-8;
// ?????°????¬??????¢??°
inline int signum(double x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }

// ???
typedef complex<double> P;
// ??????????????´????????´???
struct L { P pos, dir; };
// ????§???¢
typedef vector<P> G;
// ???
struct C { P p; double r; };

// ??????????????????????????????????¨??????????
inline double inp(const P& a, const P& b) {
	return (conj(a)*b).real();
}

// ??????????????????????????????????¨??????????
inline double outp(const P& a, const P& b) {
	return (conj(a)*b).imag();
}

// ????????????p???????????????b????°???±??????????????????????¨??????????
inline P proj(const P& p, const P& b) {
	return b*inp(p, b) / norm(b);
}

// ???p????????´???l??????????????????????¶???¨?????????????¨??????????
inline P perf(const L& l, const P& p) {
	L m = { l.pos - p, l.dir };
	return (p + (m.pos - proj(m.pos, m.dir)));
}

inline int ccw(const P& p, const P& r, const P& s) {
	P a(r - p), b(s - p);
	int sgn = signum(outp(a, b));
	if(sgn != 0)
		return sgn;
	if(a.real()*b.real() < -EPS || a.imag()*b.imag() < -EPS)
		return -1;
	if(norm(a) < norm(b) - EPS)
		return 1;
	return 0;
}

bool ss_intersects(const L& s, const L& t) {
	return (ccw(s.pos, s.pos + s.dir, t.pos) *
		ccw(s.pos, s.pos + s.dir, t.pos + t.dir) <= 0 &&
		ccw(t.pos, t.pos + t.dir, s.pos) *
		ccw(t.pos, t.pos + t.dir, s.pos + s.dir) <= 0);
}

double sp_distance(const L& s, const P& p) {
	const P r = perf(s, p);
	const double pos = ((r - s.pos) / s.dir).real();
	if(-EPS <= pos && pos <= 1 + EPS)
		return abs(r - p);
	return min(abs(s.pos - p),
		abs(s.pos + s.dir - p));
}

double ss_distance(const L& s, const L& t) {
	if(ss_intersects(s, t))
		return 0;
	double d = min(sp_distance(s, t.pos), sp_distance(s, t.pos + t.dir));
	d = min(d, sp_distance(t, s.pos));
	d = min(d, sp_distance(t, s.pos + s.dir));
	return d;
}

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

	int N;
	while(cin >> N, N) {
		double sx, sy, ex, ey;
		cin >> sx >> sy >> ex >> ey;
		L line = L{ P(sx, sy), P(ex - sx, ey - sy) };
		vector< vector<P> > g(N);
		vector<double> h;

		bool flag = false;
		for(int i = 0; i < N; i++) {
			double x1, y1, x2, y2, hh;
			cin >> x1 >> y1 >> x2 >> y2 >> hh;
			if(x1 <= sx && sx <= x2 && y1 <= sy && sy <= y2) flag = true;
			g[i].push_back(P(x1, y1));
			g[i].push_back(P(x2, y1));
			g[i].push_back(P(x2, y2));
			g[i].push_back(P(x1, y2));
			h.push_back(hh);
		}


		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 4; j++) {
				if(ss_intersects(L{ g[i][j], g[i][(j + 1) % 4] - g[i][j] }, line)) {
					flag = true;
				}
			}
		}
		if(flag) {
			cout << 0 << endl;
			continue;
		}

		double ok = 0, ng = 1000;
		for(int loop = 0; loop < 100; loop++) {
			double r = (ok + ng) / 2;
			double t = 1e8;
			for(int i = 0; i < N; i++) {
				for(int j = 0; j < 4; j++) {
					double sp = sp_distance(line, g[i][j]);
					double ss = ss_distance(line, L{ g[i][j], g[i][(j + 1) % 4] - g[i][j] });
					if(r > h[i]) {
						double l1 = sqrt(sp * sp + (h[i] - r) * (h[i] - r));
						double l2 = sqrt(ss * ss + (h[i] - r) * (h[i] - r));
						t = min(t, l1);
						t = min(t, l2);
					}
					else {
						t = min(t, sp);
						t = min(t, ss);
					}
				}
			}

			if(r < t) ok = r;
			else ng = r;
		}

		cout << ok << endl;
	}
}

Measured memory_bytes: 1356