#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

const double EPS=1e-7; //うまくいかなかったらゆるめる
typedef complex<double> P;
typedef vector<P> G;

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

namespace std{//演算子の定義
  bool operator < (const P& a,const P& b) {
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b) {
    return a.real()==b.real() && a.imag()==b.imag();
  }
}

void printP(const P &p){
  cout << shosu(10) << p.real() << " " << p.imag() << endl;
}

void printL(const L &l) {
  	cout << shosu(10) << l[0].real() << " " << l[0].imag() << " " << l[1].real() << " " << l[1].imag() << endl;
}

void printG(const G &g) {
  for(int i = 0; i < g.size(); i++){
    cout << shosu(10) << g[i].real() << " " << g[i].imag() << endl;
  }
}

P inP(){
  double x,y;
//  scanf("%lf,%lf", &x, &y);
  cin >> x >> y;
  P p(x,y);
  return p;
}

L inL(){
  P p1 = inP();
  P p2 = inP();
  L l(p1,p2);
  return l;
}

double dot(P a,P b) {
  return real(conj(a)*b);
}

double cross(P a,P b) {
  return imag(conj(a)*b);
}

P projection(const L &l, const P &p) { //pの直線l上の射影の点
  double t=dot(p-l[0],l[0]-l[1])/norm(l[0]-l[1]);
  return l[0]+t*(l[0]-l[1]);
}

int ccw(P a, P b, P c) { //3点の関係性
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;                               // a--c--b on line
}

bool intersectSP(const L &s, const P &p) { //直線と点の交差判定
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // 三角不等式
}

bool intersectSS(const L &s, const L &t) { //2線分の交差判定(完全に交差してないとだめ)
  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;
}

double distanceSP(const L &s, const P &p) {//直線と点との距離
  const 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) {//2線分の距離
  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])));
}

bool intersectSL(const L &s, const L &l){
    return cross(l[1] - l[0], s[0] - l[0]) * cross(l[1] - l[0], s[1] - l[0]) < EPS;
}



double distanceGL(const G &g, const L &l){//凸多角形と直線の距離
    double ret = LINF;
    int n = g.size();
    rep(i,n){
        L l2(g[i],g[(i+1)%n]);
        ret = min(ret, distanceSS(l2,l));
    }
    return ret;
}

int inconvex(const G& g, const P& p) { //多角形と点の関係
	bool in = false;
	int n = g.size();
	for(int i = 0; i < n; i++){
		P a = g[i%n] - p;
		P b = g[(i+1)%n] - p;
		if(imag(a) > imag(b)) swap(a, b);
		if(imag(a) < EPS && 0 < imag(b))if(cross(a,b) < 0)in = !in;
		if(abs(cross(a,b)) < EPS && dot(a,b) < EPS) return 1;//ON
	}
	return in ? 2 : 0;//IN : OUT;
}

signed main(void) {
    int n;
    while(cin >> n,n){
        L l = inL();
        vector<double> h(n),d(n);
        rep(i,n){
            int minx,miny,maxx,maxy;
            cin >> minx >> miny >> maxx >> maxy >> h[i];
            G g(4);
            P a(minx,miny),b(minx,maxy),c(maxx,maxy),e(maxx,miny);
            g[0] = a, g[1] = b, g[2] = c, g[3] = e;
            if(inconvex(g,l[0]) || inconvex(g,l[1]))d[i] = 0;
            else d[i] = distanceGL(g,l);
        }
        //rep(i,n)cout << shosu(10) << h[i] << " " << d[i] << endl;

        double ok = 0, ng = 1005;
        while(abs(ok - ng) > EPS){
            double mid = (ok + ng)/2;
            bool c = true;
            rep(i,n){
                if(h[i] >= mid){
                    if(d[i] < mid)c = false;
                }else{
                    if(mid*mid > (mid-h[i])*(mid-h[i]) + d[i]*d[i])c = false;
                }
            }
            if(c) ok = mid;
            else ng = mid;
        }
        cout << shosu(10) << ok << endl;
    }
}



Measured memory_bytes: 3304