#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF (ll)1E9
#define EPS 1E-3
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};

//constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;   // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

					   // 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
	return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
	return (conj(a)*b).Y;
}

// 点の進行方向
int ccw(P a, P b, P c) {
	b -= a;  c -= a;
	if (cross(b, c) >  EPS) return +1;  // counter clockwise
	if (cross(b, c) < -EPS) return -1;  // clockwise
	if (dot(b, c)   < -EPS) return +2;  // c--a--b on line
	if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
	return 0;                          // a--c--b on line or a==c or b==c
}

/* 交差判定　直線・線分は縮退してはならない。接する場合は交差するとみなす。isecはintersectの略 */

// 直線と点
bool isecLP(P a1, P a2, P b) {
	return abs(ccw(a1, a2, b)) != 1;  // return EQ(cross(a2-a1, b-a1), 0); と等価
}

// 直線と直線
bool isecLL(P a1, P a2, P b1, P b2) {
	return !isecLP(a2 - a1, b2 - b1, 0) || isecLP(a1, b1, b2);
}

// 直線と線分
bool isecLS(P a1, P a2, P b1, P b2) {
	return cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < EPS;
}

// 線分と線分
bool isecSS(P a1, P a2, P b1, P b2) {
	return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
		ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

// 線分と点
bool isecSP(P a1, P a2, P b) {
	return !ccw(a1, a2, b);
}


/* 距離　各直線・線分は縮退してはならない */

// 点pの直線aへの射影点を返す
P proj(P a1, P a2, P p) {
	return a1 + dot(a2 - a1, p - a1) / norm(a2 - a1) * (a2 - a1);
}

// 点pの直線aへの反射点を返す
P reflection(P a1, P a2, P p) {
	return 2.0*proj(a1, a2, p) - p;
}

D distLP(P a1, P a2, P p) {
	return abs(proj(a1, a2, p) - p);
}

D distLL(P a1, P a2, P b1, P b2) {
	return isecLL(a1, a2, b1, b2) ? 0 : distLP(a1, a2, b1);
}

D distLS(P a1, P a2, P b1, P b2) {
	return isecLS(a1, a2, b1, b2) ? 0 : min(distLP(a1, a2, b1), distLP(a1, a2, b2));
}

D distSP(P a1, P a2, P p) {
	P r = proj(a1, a2, p);
	if (isecSP(a1, a2, r)) return abs(r - p);
	return min(abs(a1 - p), abs(a2 - p));
}

D distSS(P a1, P a2, P b1, P b2) {
	if (isecSS(a1, a2, b1, b2)) return 0;
	return min(min(distSP(a1, a2, b1), distSP(a1, a2, b2)),
		min(distSP(b1, b2, a1), distSP(b1, b2, a2)));
}

// 2直線の交点
P crosspointLL(P a1, P a2, P b1, P b2) {
	D d1 = cross(b2 - b1, b1 - a1);
	D d2 = cross(b2 - b1, a2 - a1);
	if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
	if (EQ(d2, 0)) throw "kouten ga nai";   // 交点がない
	return a1 + d1 / d2 * (a2 - a1);
}



void solve(int n) {
	double ans = 100000;
	double sx, sy, ex, ey;
	vector<double> in(4), h(n) ,d(n,100000);
	complex<double> s, e, vec;
	vector<vector<complex<double>>> dat(n, vector<complex<double>>(4));
	cin >> sx >> sy >> ex >> ey;
	s = { sx,sy }; e = { ex,ey };
	bool sw = false;
	rep(i, n) {
		cin >> in[0] >> in[1] >> in[2] >> in[3] >> h[i];
		rep(j, 4) {
			complex<double> c = {in[(j/2)*2],in[(j%2)*2+1]};
			dat[i][j] = c;
		}
		if (in[0] <= sx&&sx <= in[2] &&
			in[0] <= ex&&ex <= in[2] &&
			in[1] <= sy&&sy <= in[3] &&
			in[1] <= ey&&ey <= in[3]
			)sw = true;
	}
	if (sw) {
		cout << 0 << endl;
		return;
	}
	//cout << distSS( { 8541, 5883 }, { 3011 ,-5535 } ,{ 5887,-161 }, { 5887,-152 }) << endl;
	//cout << s << " " << e << endl;
	rep(i, n) {
		double dist;
		rep(j, 4) {
			//cout << dat[i][j].real() << " "<< dat[i][j].imag() <<endl;
		}
		dist = distSS(dat[i][0], dat[i][1], s, e);
		//cout <<s<<e<< dat[i][0]<<"==="<< dat[i][1]<<" "<<dist << endl;
		d[i] = min(d[i], dist);
		dist = distSS(dat[i][0], dat[i][2], s, e);
		//cout << dat[i][0] << "===" << dat[i][2] << " " << dist << endl;
		d[i] = min(d[i], dist);
		dist = distSS(dat[i][1], dat[i][3], s, e);
		//cout << dat[i][1] << "===" << dat[i][3] << " " << dist << endl;
		d[i] = min(d[i], dist);
		dist = distSS(dat[i][2], dat[i][3], s, e);
		//cout << dat[i][2] << "===" << dat[i][3] << " " << dist << endl;
		d[i] = min(d[i], dist);
		//cout << endl;
	}
	//cout << d << endl;
	rep(i, n) {
		double r;
		if (d[i] <= h[i])r = d[i];
		else {
			r=(h[i] * h[i] + d[i] * d[i]) / (2 * h[i]);
		}
		//cout << r << endl;
		ans = min(ans, r);
	}
	cout << setprecision(15) <<ans << endl;

}

int main(void) {
	int n;
	while (cin >> n, n) {
		solve(n);
	}
}




Measured memory_bytes: 3272