//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-8;
const double PI  = acos(-1.0);

struct P{
  double x;
  double y;

  P():x(0),y(0){
  }

  P(const double &s , const double &e)
  { x=s; y=e;}

  P operator - (const P &t) const
  { return P(x-t.x , y-t.y); }

  P operator + (const P &t) const
  { return P(x+t.x , y+t.y); }

  P operator * (const double &d) const
  { return P(x*d , y*d); }

};
double dot(P a,P b){
  return (a.x*b.x+a.y*b.y);
}

double cross(P a,P b){
  return (a.x*b.y-a.y*b.x);
}
double dis(P t){
  return sqrt(t.x*t.x+t.y*t.y);
}
double psd(P p , P a , P b){
  if( dot( b-a , p-a ) < EPS) return fabs(dis(p-a));
  if( dot( a-b , p-b ) < EPS) return fabs(dis(p-b));
  return fabs(cross( b-a , p-a )) / fabs(dis(b-a));
}

bool intersect_s(P a1 , P a2 , P b1 , P b2){
  return ( cross(a2-a1 , b1-a1)*cross(a2-a1 , b2-a1) < 0) &&
	( cross(b2-b1 , a1-b1)*cross(b2-b1 , a2-b1) < 0);
}

double dist_s(P p1, P p2, P q1, P q2){
  if(intersect_s(p1,p2,q1,q2)) return 0;
  return min(min(psd(p1, q1, q2), psd(p2, q1, q2)),
			 min(psd(q1, p1, p2), psd(q2, p1, p2)));
}

bool isin(P p, P a1, P a2){
  double mx = min(a1.x, a2.x), Mx = max(a1.x, a2.x);
  double my = min(a1.y, a2.y), My = max(a1.y, a2.y);
  return mx <= p.x && p.x <= Mx
	&& my <= p.y  && p.y <= My;
}

int main(){
  int N;
  while(cin>>N,N){
	P s, e;
	vector< vector<P> > ps(N, vector<P>(4));
	vector<double> h(N), d(N, 1e+10);
	cin >> s.x >> s.y >> e.x >> e.y;
	REP(i,N){
	  cin >> ps[i][0].x >> ps[i][0].y >> ps[i][2].x >> ps[i][2].y >> h[i];
	  ps[i][1].x = ps[i][0].x;
	  ps[i][1].y = ps[i][2].y;

	  ps[i][3].x = ps[i][2].x;
	  ps[i][3].y = ps[i][0].y;
	}

	bool ng = false;
	REP(i,N){
	  if(isin(s, ps[i][0], ps[i][2]) || isin(e, ps[i][0], ps[i][2]))
		ng = true;
	  REP(j,4)
		if(intersect_s(s,e,ps[i][j],ps[i][(j+1)%4]))
		   ng = true;
	}
	if(ng){
	  cout << 0 << endl;
	  continue;
	}

	REP(i,N) REP(j,4){
	  d[i] = min(d[i], dist_s(s, e, ps[i][j], ps[i][(j+1)%4]));
	}

	double r = 1100.;
	REP(j,N){
	  if(d[j] < h[j])
		r = min(r, d[j]);
	  else{
		double r_ = (h[j]*h[j] + d[j]*d[j]) / (2.*h[j]);
		r = min(r, r_);
	  }
	}

	cout << fixed << setprecision(6) << r << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1308