#include<iostream>
#include<complex>
#include<algorithm>
#include<cmath>

#define EPS (1e-10)
#define fs first
#define sc second

using namespace std;

typedef complex<int> P;
typedef pair<P,P> L;

//for vector

int dot(P x,P y){return real(conj(x)*y);}

int cross(P x,P y){return imag(conj(x)*y);}

double dis(P x, P y){
  return sqrt( (real(x)-real(y))*(real(x)-real(y)) 
	       + (imag(x)-imag(y))*(imag(x)-imag(y)) );
}

double norm(P x){return sqrt(real(x)*real(x) + imag(x)*imag(x) );}

//for line(segment)
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
  return 0;                       //on segment
}

double seg_dis(L a,P x){
  if(dot(a.sc-a.fs,x-a.fs)<EPS)return dis(x,a.fs);
  if(dot(a.fs-a.sc,x-a.sc)<EPS)return dis(x,a.sc);
  return abs((double)cross(a.sc-a.fs,x-a.fs))/dis(a.sc,a.fs);
}

bool is_cp(L a,L b){
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

double seg_close(L a, L b){
  double res = 1e10;
  res = min(res, seg_dis(a,b.first));
  res = min(res, seg_dis(a,b.second));
  res = min(res, seg_dis(b,a.first));
  res = min(res, seg_dis(b,a.second));
  return res;
}

int main(){
  int n,sx,sy,ex,ey;
  int x1,y1,x2,y2,h;

  while(cin >> n ,n){
    cin >> sx >> sy >> ex >> ey;
    L l = L(P(sx,sy),P(ex,ey));

    double r = 100000.0;
    for(int i=0;i<n;i++){
      cin >> x1 >> y1 >> x2 >> y2 >> h;
      if(r<EPS)continue;

      if(x1>x2)swap(x1,x2);
      if(y1>y2)swap(y1,y2);
      L A = L(P(x1,y1),P(x1,y2));
      L B = L(P(x1,y2),P(x2,y2));
      L C = L(P(x2,y2),P(x2,y1));
      L D = L(P(x2,y1),P(x1,y1));

      if(is_cp(l,A))r = 0.0;
      else if(is_cp(l,B))r = 0.0;
      else if(is_cp(l,C))r = 0.0;
      else if(is_cp(l,D))r = 0.0;
      else if(x1<=sx && sx<=x2 && y1<=sy && sy<=y2)r = 0.0;
      else{
	double dis = min(min(seg_close(l,A),seg_close(l,B)),
			 min(seg_close(l,C),seg_close(l,D)));
	if(dis<h)r = min(r,dis);
	else r = min(r,(h*h+dis*dis)/(2*h));
      }
    }
    cout << r << endl;
  }
}