#include <iostream>
#include <cmath>
#include <complex>
#include <vector>
using namespace std;

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

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

typedef vector<P> G;

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  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;
}





//線分x線分交差判定
bool intersectSS(const L &s, const L &t) {
  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;
}

//線分x点交差判定
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}


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

//線分と点の距離
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) {
  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])));
}

int i,j,t;

int main(){
	int N,i,j;
	while(cin>>N, N){
		double x1,y1,x2,y2,h,Min = 1e6;
		P S,E;
		cin >> x1>>y1>>x2>>y2;
		S = P(x1, y1);
		E = P(x2, y2);
		for(i=0;i<N;i++){
			cin >> x1>>y1>>x2>>y2>>h;
			P p1 = P(x1,y1);
			P p2 = P(x1,y2);
			P p3 = P(x2,y1);
			P p4 = P(x2,y2);
			double l = distanceSS(L(p1, p2), L(S, E));
			if(distanceSS(L(p2, p4), L(S, E)) < l) l = distanceSS(L(p2, p4), L(S, E));
			if(distanceSS(L(p3, p4), L(S, E)) < l) l = distanceSS(L(p3, p4), L(S, E));
			if(distanceSS(L(p1, p3), L(S, E)) < l) l = distanceSS(L(p1, p3), L(S, E));
			double a;
			if(l < h) a = l;
			else{
				a = (h*h+l*l)/(2*h);
			}
			if(x1 < real(S) && y1 < imag(S) && real(S) < x2 && imag(S) < y2) a = 0;
			Min = min(Min, a);
		}
		printf("%.4lf\n", Min);
	}
}	